以下是我的 GitHub 工作流程
name: APP Build
on:
push:
branches:
- feature/test
jobs:
test-1:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' && contains( github.event.head_commit.message, 'test1') }}
steps:
- name: test-fail
run: echo "test1"
test-2:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' && contains( github.event.head_commit.message, 'test2') }}
steps:
- name: test-fail
run: echo "test1"
notify-slack:
name: Slack Notification
runs-on: ubuntu-latest
needs: [test-1, test-2]
steps:
- name: Slack Notification
uses: rtCamp/action-slack-notify@v2.2.0
env:
SLACK_CHANNEL: alert
SLACK_COLOR: "${{ job.status == 'success' && 'good' || 'danger' }}"
问题:我的提交消息决定了
test1
和test2
任务的条件性, 但是通知slack需要test1
或test2
。我不能把两者都放进去,因为如果其中一个任务跳过了,那么notify-slack
也会被跳过。该如何解决这个问题?
if: | always() && (needs.check-environment.result == 'success' || needs.check-environment.result == 'skipped') && (needs.deploy.result == 'success' || needs.deploy.result == 'skipped') && (needs.restart-pods.result == 'success' || needs.restart-pods.result == 'skipped') && (github.event_name == 'pull_request')
- Vikas Rathore(needs.test-1.result == 'success' || needs.test-2.result == 'success')
所以现在它应该在其中一个是success
或skipped
时触发,但当两者都不是success
时不会触发。这是预期行为吗?或者我们也应该在两者都被跳过时触发此步骤? - Krzysztof Madej