|
| 1 | +name: Fly Preview |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request_target: |
| 5 | + branches: [main] |
| 6 | + |
| 7 | +permissions: |
| 8 | + contents: read |
| 9 | + pull-requests: write |
| 10 | + |
| 11 | +jobs: |
| 12 | + fly_preview: |
| 13 | + if: github.event.pull_request.draft == false |
| 14 | + runs-on: ubuntu-latest |
| 15 | + environment: ${{ github.event.pull_request.head.repo.full_name != github.repository && 'preview' || '' }} |
| 16 | + env: |
| 17 | + FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} |
| 18 | + concurrency: |
| 19 | + group: pr-${{ github.event.pull_request.number }} |
| 20 | + |
| 21 | + steps: |
| 22 | + - name: Checkout PR head |
| 23 | + uses: actions/checkout@v4 |
| 24 | + with: |
| 25 | + ref: ${{ github.event.pull_request.head.sha }} |
| 26 | + |
| 27 | + - name: Find existing comment |
| 28 | + uses: peter-evans/find-comment@v3 |
| 29 | + id: fc |
| 30 | + with: |
| 31 | + issue-number: ${{ github.event.pull_request.number }} |
| 32 | + comment-author: 'github-actions[bot]' |
| 33 | + body-includes: '<!-- fly-preview-counterslayer -->' |
| 34 | + |
| 35 | + - name: Create or update comment (deploying) |
| 36 | + uses: peter-evans/create-or-update-comment@v3 |
| 37 | + with: |
| 38 | + comment-id: ${{ steps.fc.outputs.comment-id }} |
| 39 | + issue-number: ${{ github.event.pull_request.number }} |
| 40 | + edit-mode: replace |
| 41 | + body: | |
| 42 | + <!-- fly-preview-counterslayer --> |
| 43 | + ### Fly Preview Deployment - In Progress :rocket: |
| 44 | +
|
| 45 | + Deploying preview to [Fly.io](https://fly.io/apps/pr-${{ github.event.pull_request.number }}-counterslayer/monitoring)... |
| 46 | +
|
| 47 | + - name: Deploy preview |
| 48 | + uses: superfly/fly-pr-review-apps@1.3.0 |
| 49 | + with: |
| 50 | + name: pr-${{ github.event.pull_request.number }}-counterslayer |
| 51 | + config: fly.dev.toml |
| 52 | + org: siege-perilous |
| 53 | + |
| 54 | + - name: Find comment after deploy |
| 55 | + uses: peter-evans/find-comment@v3 |
| 56 | + id: fc2 |
| 57 | + with: |
| 58 | + issue-number: ${{ github.event.pull_request.number }} |
| 59 | + comment-author: 'github-actions[bot]' |
| 60 | + body-includes: '<!-- fly-preview-counterslayer -->' |
| 61 | + |
| 62 | + - name: Update comment (success) |
| 63 | + uses: peter-evans/create-or-update-comment@v3 |
| 64 | + with: |
| 65 | + comment-id: ${{ steps.fc2.outputs.comment-id }} |
| 66 | + issue-number: ${{ github.event.pull_request.number }} |
| 67 | + edit-mode: replace |
| 68 | + body: | |
| 69 | + <!-- fly-preview-counterslayer --> |
| 70 | + ### Fly Preview Deployment - Completed :white_check_mark: |
| 71 | +
|
| 72 | + - [Preview](https://pr-${{ github.event.pull_request.number }}-counterslayer.fly.dev) - [Fly Dashboard](https://fly.io/apps/pr-${{ github.event.pull_request.number }}-counterslayer/monitoring) |
| 73 | +
|
| 74 | + - name: Update comment (failure) |
| 75 | + if: failure() |
| 76 | + uses: peter-evans/create-or-update-comment@v3 |
| 77 | + with: |
| 78 | + comment-id: ${{ steps.fc2.outputs.comment-id }} |
| 79 | + issue-number: ${{ github.event.pull_request.number }} |
| 80 | + edit-mode: replace |
| 81 | + body: | |
| 82 | + <!-- fly-preview-counterslayer --> |
| 83 | + ### Fly Preview Deployment - Failed :x: |
| 84 | +
|
| 85 | + Check the [workflow logs](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) for details. |
0 commit comments