|
1 | 1 | name: Deploy Review App |
2 | 2 | on: |
3 | 3 | # Run this workflow on every PR event. Existing review apps will be updated when the PR is updated. |
4 | | - pull_request: |
5 | | - types: [opened, reopened, synchronize, closed] |
| 4 | + # pull_request: |
| 5 | + # types: [opened, reopened, synchronize, closed] |
| 6 | + # Add trigger for comments on PRs |
| 7 | + issue_comment: |
| 8 | + types: [created, edited] |
6 | 9 |
|
7 | 10 | env: |
8 | 11 | FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} |
|
11 | 14 | jobs: |
12 | 15 | review_app: |
13 | 16 | runs-on: ubuntu-latest |
| 17 | + # Run if commented by me |
| 18 | + if: | |
| 19 | + github.event_name == 'pull_request' || |
| 20 | + (github.event_name == 'issue_comment' && |
| 21 | + github.event.issue.pull_request && |
| 22 | + contains(github.event.comment.body, '/deploy') && |
| 23 | + github.event.comment.user.login == 'unkn-wn') |
14 | 24 | outputs: |
15 | 25 | url: ${{ steps.deploy.outputs.url }} |
16 | 26 | # Only run one deployment at a time per PR. |
17 | 27 | concurrency: |
18 | | - group: pr-${{ github.event.number }} |
| 28 | + group: pr-${{ github.event.issue.number }} |
19 | 29 |
|
20 | 30 | # Deploying apps with this "review" environment allows the URL for the app to be displayed in the PR UI. |
21 | 31 | # Feel free to change the name of this environment. |
|
26 | 36 | steps: |
27 | 37 | - name: Get code |
28 | 38 | uses: actions/checkout@v4 |
| 39 | + with: |
| 40 | + # For comment events, we need to checkout the PR's code |
| 41 | + ref: ${{ github.event_name == 'issue_comment' && format('refs/pull/{0}/head', github.event.issue.number) || '' }} |
29 | 42 |
|
30 | 43 | - name: Deploy PR app to Fly.io |
31 | 44 | id: deploy |
|
0 commit comments