|
1 | 1 | name: Deploy PR previews |
2 | 2 |
|
3 | 3 | on: |
| 4 | + pull_request: |
| 5 | + branches: |
| 6 | + - main |
4 | 7 | pull_request_target: |
| 8 | + types: |
| 9 | + - opened |
| 10 | + - reopened |
| 11 | + - labeled |
| 12 | + - synchronize |
5 | 13 | branches: |
6 | 14 | - main |
7 | 15 |
|
8 | | - paths: |
9 | | - - "**/*.*" |
10 | | - - "!package.json" |
11 | | - - "!.github/workflows" |
12 | | - |
13 | 16 | env: |
14 | 17 | DEPLOY_REPO_OWNER: OpenDreamProject |
15 | 18 | DEPLOY_REPO: od-dm-reference |
16 | 19 |
|
17 | | -concurrency: preview-${{ github.ref }} |
| 20 | +concurrency: |
| 21 | + group: "ci-security-${{ github.head_ref || github.run_id }}-${{ github.event_name }}" |
| 22 | + cancel-in-progress: true |
18 | 23 |
|
19 | 24 | jobs: |
| 25 | + security-checkpoint: |
| 26 | + name: Check CI Clearance |
| 27 | + if: github.event_name == 'pull_request_target' && (github.event.pull_request.head.repo.id != github.event.pull_request.base.repo.id || github.event.pull_request.user.id == 55142896) && github.event.pull_request.state == 'open' |
| 28 | + runs-on: ubuntu-latest |
| 29 | + steps: |
| 30 | + - name: "Remove Stale 'CI Cleared' Label" |
| 31 | + if: github.event.action == 'synchronize' || github.event.action == 'reopened' |
| 32 | + uses: actions-ecosystem/action-remove-labels@2ce5d41b4b6aa8503e285553f75ed56e0a40bae0 |
| 33 | + with: |
| 34 | + labels: CI Cleared |
| 35 | + |
| 36 | + - name: "Remove 'CI Approval Required' Label" |
| 37 | + if: (github.event.action == 'synchronize' || github.event.action == 'reopened') || ((github.event.action == 'opened' || github.event.action == 'labeled') && contains(github.event.pull_request.labels.*.name, 'CI Cleared')) |
| 38 | + uses: actions-ecosystem/action-remove-labels@2ce5d41b4b6aa8503e285553f75ed56e0a40bae0 |
| 39 | + with: |
| 40 | + labels: CI Approval Required |
| 41 | + |
| 42 | + - name: "Add 'CI Approval Required' Label" |
| 43 | + if: (github.event.action == 'synchronize' || github.event.action == 'reopened') || ((github.event.action == 'opened' || github.event.action == 'labeled') && !contains(github.event.pull_request.labels.*.name, 'CI Cleared')) |
| 44 | + uses: actions-ecosystem/action-add-labels@18f1af5e3544586314bbe15c0273249c770b2daf |
| 45 | + with: |
| 46 | + labels: CI Approval Required |
| 47 | + |
| 48 | + - name: Fail if PR has Unlabeled new Commits from User |
| 49 | + if: (github.event.action == 'synchronize' || github.event.action == 'reopened') || ((github.event.action == 'opened' || github.event.action == 'labeled') && !contains(github.event.pull_request.labels.*.name, 'CI Cleared')) |
| 50 | + run: exit 1 |
| 51 | + |
20 | 52 | deploy-preview: |
| 53 | + needs: security-checkpoint |
| 54 | + if: (!(cancelled() || failure()) && (needs.security-checkpoint.result == 'success' || (github.event_name != 'pull_request_target' && github.event.pull_request.head.repo.id == github.event.pull_request.base.repo.id && github.event.pull_request.user.id != 55142896))) |
21 | 55 | runs-on: ubuntu-latest |
22 | 56 | steps: |
23 | 57 | - name: Checkout repo |
24 | 58 | uses: actions/checkout@v4 |
| 59 | + with: |
| 60 | + ref: refs/pull/${{ github.event.number }}/merge |
25 | 61 |
|
26 | 62 | - name: Setup Node |
27 | 63 | uses: actions/setup-node@v4 |
|
0 commit comments