Skip to content
This repository has been archived by the owner on May 22, 2023. It is now read-only.

Commit

Permalink
fix: use /review-apps endpoint for deletion rather than /app endpoint (
Browse files Browse the repository at this point in the history
…#19)

* doc: update description about differences between v1 & v2

* Fix pr-predestroy script not running

The pr-predestroy script is normally run when a PR is closed and its
review app is destroyed[1]. In the current release (v2.0.0) it is not
being triggered.

This commit fixes that by calling the /review-apps endpoint instead
of the /apps endpoint to delete the review app.

[1] https://devcenter.heroku.com/articles/github-integration-review-apps#pr-predestroy-script

Co-authored-by: Peter Mbanugo <[email protected]>
  • Loading branch information
ch2ch3 and pmbanugo authored May 18, 2022
1 parent 3c32b47 commit f2ea9ca
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ Earlier version from v1.0 created apps and placed them into the pipeline as a re

In order to utilise the config vars defined for review apps, I decided to use the _/review-apps_ Heroku API endpoint for v2 of this action. There are less things to configure, therefore the inputs are different and caused a breaking change. Both versions are stable and serves different use-cases. Bug fixes will still be treated for both, but with the most focus on v2.

If you use v1.x and want to see the README for v1.x, switch to the v1.x [branch](/tree/v1.x).
### How to choose?

If you already have review apps enabled for your pipeline, use v2. If you have a pipeline with review apps disabled, use v1.2.x.

If you use v1.x and want to see the README for v1.x, switch to the v1.x [branch](/tree/v1.x). The main branch has code for v2.x.

## Sponsor

Expand Down
7 changes: 6 additions & 1 deletion action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,12 @@ runs:
if: ${{ github.event_name == 'pull_request' && github.event.action == 'closed' }}
shell: bash
run: |
curl -X DELETE https://api.heroku.com/apps/$APP_NAME \
export REVIEW_APP_ID=$(curl -X GET https://api.heroku.com/apps/$APP_NAME/review-app \
-H 'Accept: application/vnd.heroku+json; version=3' \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${{ inputs.api-key }}" | \
jq -r '.id')
curl -X DELETE https://api.heroku.com/review-apps/$REVIEW_APP_ID \
-H "Content-Type: application/json" \
-H "Accept: application/vnd.heroku+json; version=3" \
-H "Authorization: Bearer ${{ inputs.api-key }}"

0 comments on commit f2ea9ca

Please sign in to comment.