|
6 | 6 | issue_comment: |
7 | 7 | types: [created] |
8 | 8 |
|
| 9 | +# Use concurrency to cancel in-progress runs |
| 10 | +concurrency: |
| 11 | + group: deploy-${{ github.event.pull_request.number || github.event.issue.number }} |
| 12 | + cancel-in-progress: true |
| 13 | + |
9 | 14 | env: |
10 | 15 | APP_NAME: qa-react-webpack-rails-tutorial-pr-${{ github.event.pull_request.number || github.event.issue.number }} |
11 | 16 | CPLN_ORG: ${{ secrets.CPLN_ORG }} |
12 | 17 | PR_NUMBER: ${{ github.event.pull_request.number || github.event.issue.number }} |
13 | 18 |
|
14 | 19 | jobs: |
15 | | - check-concurrent: |
16 | | - name: Check concurrent deployments |
17 | | - runs-on: ubuntu-latest |
18 | | - outputs: |
19 | | - cancelled: ${{ steps.check.outputs.cancelled }} |
20 | | - steps: |
21 | | - - uses: actions/github-script@v7 |
22 | | - id: check |
23 | | - with: |
24 | | - script: | |
25 | | - const runs = await github.rest.actions.listWorkflowRuns({ |
26 | | - owner: context.repo.owner, |
27 | | - repo: context.repo.repo, |
28 | | - workflow_id: context.workflow, |
29 | | - status: 'in_progress', |
30 | | - branch: context.payload.pull_request?.head.ref |
31 | | - }); |
32 | | - core.setOutput('cancelled', runs.data.total_count > 1 ? 'true' : 'false'); |
33 | | -
|
34 | 20 | deploy: |
35 | | - needs: check-concurrent |
36 | 21 | if: | |
37 | | - needs.check-concurrent.outputs.cancelled != 'true' && |
38 | | - ((github.event_name == 'pull_request') || |
39 | | - (github.event_name == 'issue_comment' && github.event.comment.body == '/deploy-review-app')) |
| 22 | + github.event_name == 'pull_request' || |
| 23 | + (github.event_name == 'issue_comment' && |
| 24 | + github.event.comment.body == '/deploy-review-app' && |
| 25 | + github.event.issue.pull_request) |
40 | 26 | runs-on: ubuntu-latest |
41 | 27 | permissions: |
42 | 28 | contents: read |
|
0 commit comments