✨ feat: support bypass CI by approve (#9) #55
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Example Workflow | |
on: | |
pull_request: | |
branches: | |
- main | |
push: | |
branches: | |
- main | |
env: | |
ACTIONS_RUNNER_DEBUG: true | |
jobs: | |
check-bypass: | |
name: Check Bypass | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
outputs: | |
can-skip: ${{ steps.check-bypass.outputs.can-skip }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- id: check-bypass | |
name: Check Bypass | |
uses: ./ | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
non-pull-request-event-strategy: 'always-skipped' | |
# type: "labeled" | |
# label: "ci-bypass: example | ci-bypass: all" | |
# username: "SigureMo" | |
type: 'composite' | |
composite-rule: | | |
{ | |
"any": [ | |
{ | |
"type": "labeled", | |
"label": ["ci-bypass: example", "ci-bypass: all"], | |
"username": ["SigureMo"] | |
}, | |
{ | |
"type": "commented", | |
"comment-pattern": [".+/bypass example.+", ".+/bypass all.+"], | |
"username": ["SigureMo"] | |
}, | |
{ | |
"type": "approved", | |
"username": ["SigureMo", "gouzil"] | |
} | |
] | |
} | |
test-action-not-bypass: | |
needs: check-bypass | |
if: ${{ needs.check-bypass.outputs.can-skip != 'true' }} | |
name: Branch not bypass | |
runs-on: ubuntu-latest | |
steps: | |
- name: Action Not Skipped | |
id: not-bypass | |
run: echo "::error ::Action not skipped, needs.check-bypass.outputs.can-skip is ${{ needs.check-bypass.outputs.can-skip }}" | |
test-action-bypass: | |
needs: check-bypass | |
if: ${{ needs.check-bypass.outputs.can-skip == 'true' }} | |
name: Branch bypass | |
runs-on: ubuntu-latest | |
steps: | |
- name: Action Skipped | |
id: bypass | |
run: echo "::error ::Action skipped" |