if: always () with another if condition
Closed this issue · 1 comments
Is your feature request related to a problem? Please describe.
This is more of a question as It could be lack of YAML knowledge on my end. However, I'm having a hard time getting if: always ()
to work, because I have an if:
statement already being used to identify which environment we're using.
This works just fine, without if: always ()
Example (modified for randomness)
name: SomeTest
on:
repository_dispatch:
types: [SomeTest]
jobs:
build:
runs-on: ubuntu-latest
env:
ENV: ${{ github.event.client_payload.env }}
A_CICD_JOB: ${{ github.event.client_payload.repo_name }}
BRANCH_NAME: ${{ github.event.client_payload.branch_name }}
steps:
- uses: actions/checkout@v2
- name: Set up JDK XX
<BUILD SOME STUFF>
...
...
...
- name: Slack Notify Status UAT
uses: act10ns/slack@v1
if: ${{ env.ENV }} == 'uat'
with:
webhook-url: ${{ secrets.UAT_SOMETEST_SLACK_WEBHOOK_URL }}
status: ${{ job.status }}
channel: '#uat-somechannel'
message: GitHub some test result "${{ job.status }}" on ${{ env.A_CICD_JOB }} - ${{ env.BRANCH_NAME }}
- name: Slack Notify Status Staging
uses: act10ns/slack@v1
if: ${{ env.ENV }} == 'staging'
with:
webhook-url: ${{ secrets.STAGING_SOMETEST_SLACK_WEBHOOK_URL }}
status: ${{ job.status }}
channel: '#staging-somechannel'
message: GitHub some test result "${{ job.status }}" on ${{ env.A_CICD_JOB }} - ${{ env.BRANCH_NAME }}
I've tried various combinations, like so (same for 'staging'):
- which gets no failure notifications, and posts in both slack channels above, during success
uses: act10ns/slack@v1
if: |
always() &&
${{ env.ENV }} == 'uat'
with:
I've also tried a simple always() && ${{ env.ENV }} == 'uat'
however, same results as directly above.
Describe the solution you'd like
I think I may just be missing something, if not:
- can we have another way to report statuses besides success that don't require
if:
?
Describe alternatives you've considered
I can just create two workflow files, however I wanted to check here first as a last option before duplicating that much code.
Additional context
I am using web hooks, not slack apps.
Thank you very much!
I did wind up just using two separate workflow files, so I'm all set. Still curious though! TBH since there is only IF (no Else/Then) in GitHub actions I'm not too concerned about small DRY issues as I already had that going on in the example above.