|
11 | 11 | - dev
|
12 | 12 | paths:
|
13 | 13 | - 'apps/www/**'
|
14 |
| - # Triggers the workflow on pull request event, but only for pull request opened or pull request labeled with "🚀request-deploy" (from forked repo) |
15 |
| - # pull_request is not allowed to use secrets, so we use pull_request_target instead (in forked repos) |
16 |
| - pull_request_target: |
17 |
| - types: |
18 |
| - # When a created pull request from forked repo, it will be comment 'Should deploy to add label' |
19 |
| - - opened |
20 |
| - # When a labeled '🚀request-deploy' pull request from forked repo, it will be deploy to Cloudflare Pages |
21 |
| - - labeled |
22 |
| - |
23 |
| -permissions: |
24 |
| - # default contents: read & write (in forked repos, only read) |
25 |
| - contents: write |
26 |
| - # default deployments: read & write (in forked repos, only read) |
27 |
| - deployments: write |
28 |
| - # default pull-requests: read & write (in forked repos, only read) |
29 |
| - pull-requests: write |
30 | 14 |
|
31 | 15 | jobs:
|
32 | 16 | publish:
|
33 | 17 | runs-on: ubuntu-latest
|
| 18 | + permissions: |
| 19 | + contents: read |
| 20 | + deployments: write |
34 | 21 | name: Publish to Cloudflare Pages
|
35 |
| - if: ${{ |
36 |
| - github.event_name == 'push' || |
37 |
| - github.event_name == 'workflow_dispatch' || |
38 |
| - github.event_name == 'pull_request' || |
39 |
| - (github.event_name == 'pull_request_target' && |
40 |
| - github.event.action == 'labeled' && |
41 |
| - github.event.pull_request.head.repo.fork == true && |
42 |
| - contains(github.event.label.name, '🚀request-deploy')) |
43 |
| - }} |
44 |
| - |
45 | 22 | steps:
|
46 | 23 | - name: Checkout
|
47 | 24 | uses: actions/checkout@v3
|
|
93 | 70 | # Optional: Change the working directory
|
94 | 71 | workingDirectory: apps/www
|
95 | 72 | wranglerVersion: '3'
|
96 |
| - |
97 |
| - - name: Remove label |
98 |
| - if: ${{ github.event_name == 'pull_request_target' && contains(github.event.label.name, '🚀request-deploy') }} |
99 |
| - uses: actions/github-script@v6 |
100 |
| - with: |
101 |
| - github-token: ${{ secrets.GITHUB_TOKEN }} |
102 |
| - script: | |
103 |
| - github.rest.issues.removeLabel({ |
104 |
| - issue_number: context.issue.number, |
105 |
| - owner: context.repo.owner, |
106 |
| - repo: context.repo.repo, |
107 |
| - name: ['🚀request-deploy'] |
108 |
| - }) |
0 commit comments