下面是我的 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' }}"
Run Code Online (Sandbox Code Playgroud)
问题:根据我的提交消息,工作是有条件的,但通知松弛test1需要或。我不能把两者都放在一起,因为如果其中任何一个作业也会跳过。如何使这项工作有效?test2test1test2notify-slack
Krz*_*tof 13
Github上有一个关于此的问题。您需要添加如下条件:
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]
if: |
always() &&
(needs.test-1.result == 'success' || needs.test-1.result == 'skipped') &&
(needs.test-2.result == 'success' || needs.test-2.result == 'skipped') &&
!(needs.test-1.result == 'skipped' && needs.test-2.result == 'skipped')
steps:
- name: Slack Notification
uses: rtCamp/action-slack-notify@v2.2.0
env:
SLACK_CHANNEL: alert
SLACK_COLOR: "${{ job.status == 'success' && 'good' || 'danger' }}"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
10558 次 |
| 最近记录: |