Skip to content

Commit

Permalink
ci: fix the way to check labels before running unsafe workflows
Browse files Browse the repository at this point in the history
Signed-off-by: Kenji Miyake <kenji.miyake@tier4.jp>
  • Loading branch information
Kenji Miyake committed Dec 13, 2021
1 parent baa2d2f commit dcc92d0
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 11 deletions.
42 changes: 36 additions & 6 deletions .github/workflows/build-and-test-arm-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,49 @@ name: build-and-test-arm-pr

on:
pull_request:
types:
- opened
- synchronize
- labeled
workflow_dispatch:

jobs:
check-run-condition:
runs-on: ubuntu-latest
outputs:
run: ${{ steps.check-run-condition.outputs.run }}
steps:
- name: Check run condition
id: check-run-condition
run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then
# Labeled now
if [ "${{ github.event.label.name == 'ARM64' }}" = "true" ]; then
RUN=true
fi
# Labeled before and synchronized
if [ "${{ github.event.label.name }}" = "" ]; then
if [ "${{ contains(github.event.pull_request.labels.*.name, 'ARM64') }}" = "true" ]; then
RUN=true
fi
fi
elif [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
RUN=true
fi
if [ "$RUN" != "true" ]; then
echo "Please add a proper label to run this workflow."
fi
echo ::set-output name=run::"$RUN"
build-and-test-arm:
needs: check-run-condition
if: ${{ needs.check-run-condition.outputs.run == 'true' }}
runs-on: [self-hosted, linux, ARM64]
container: ros:galactic
steps:
- name: Check label
if: ${{ github.event.pull_request && !contains(github.event.pull_request.labels.*.name, 'ARM64') }}
run: |
echo "Please add a proper label to run this workflow."
exit 1
- name: Checkout repository
uses: actions/checkout@v2
with:
Expand Down
36 changes: 31 additions & 5 deletions .github/workflows/deploy-docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,41 @@ on:
workflow_dispatch:

jobs:
deploy-docs:
check-run-condition:
runs-on: ubuntu-latest
outputs:
run: ${{ steps.check-run-condition.outputs.run }}
steps:
- name: Check label
if: ${{ github.event.pull_request && !contains(github.event.pull_request.labels.*.name, 'documentation') }}
- name: Check run condition
id: check-run-condition
run: |
echo "Please add a proper label to run this workflow."
exit 1
if [ "${{ github.event_name }}" = "pull_request" ]; then
# Labeled now
if [ "${{ github.event.label.name == 'documentation' }}" = "true" ]; then
RUN=true
fi
# Labeled before and synchronized
if [ "${{ github.event.label.name }}" = "" ]; then
if [ "${{ contains(github.event.pull_request.labels.*.name, 'documentation') }}" = "true" ]; then
RUN=true
fi
fi
elif [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
RUN=true
fi
if [ "$RUN" != "true" ]; then
echo "Please add a proper label to run this workflow."
fi
echo ::set-output name=run::"$RUN"
deploy-docs:
needs: check-run-condition
if: ${{ needs.check-run-condition.outputs.run }}
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
Expand Down

0 comments on commit dcc92d0

Please sign in to comment.