Skip to content

Commit

Permalink
[CI] Delete deploy environment on pr close (#18)
Browse files Browse the repository at this point in the history
* [CI] Delete env on pr close

* Remove pr comments
  • Loading branch information
MNThomson committed Jan 18, 2023
1 parent e6e93e7 commit 3971c9b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 21 deletions.
21 changes: 0 additions & 21 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,24 +66,3 @@ jobs:
env: ${{ env.env_name }}
env_url: ${{ github.ref != 'refs/heads/master' && format('{0}-{1}{2}', 'https://pr', github.event.number, '.containerflare.pages.dev') || 'https://cfcr.dev' }}
debug: true

- name: Find PR comment
uses: peter-evans/find-comment@v2
id: fc
with:
issue-number: ${{ github.event.number }}
comment-author: "github-actions[bot]"
body-includes: "preview of this pull request"
if: github.event_name == 'pull_request'

- name: Comment on PR
uses: peter-evans/create-or-update-comment@v2
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.number }}
body: |
A preview of this pull request is ready!
See it at ${{ github.ref != 'refs/heads/master' && format('{0}-{1}{2}', 'https://pr', github.event.number, '.containerflare.pages.dev') || 'https://cfcr.dev' }}
View the deploy log at https://github.com/MNThomson/containerflare/actions/runs/${{ github.run_id}}
edit-mode: replace
if: github.event_name == 'pull_request'
5 changes: 5 additions & 0 deletions .github/workflows/pull_request_cleanup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ on:

jobs:
cleanup:
permissions:
deployments: write
environment:
name: ${{ format('{0}-{1}', 'pr', github.event.number) }}
name: Delete environment
runs-on: ubuntu-latest
steps:
- name: Delete deployment
Expand Down

0 comments on commit 3971c9b

Please sign in to comment.