Skip to content

Commit

Permalink
Mark GitHub Deployments as inactive and delete associated environment…
Browse files Browse the repository at this point in the history
…s once PRs have been closed (#92)
  • Loading branch information
justafish authored Mar 30, 2022
1 parent a2fbce5 commit 067f741
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions scaffold/github/actions/pantheon/review/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ runs:
# if $MULTIDEV starts with "pr-"
elif [[ $MULTIDEV == pr-* ]]; then
echo "No PR for $MULTIDEV, shutting down..."
DEPLOYMENTS=$(curl -s -f -H "Authorization: token ${{ inputs.github-token }}" -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/$GITHUB_REPOSITORY/deployments?environment=pantheon-$MULTIDEV | jq '.[] | .id')
for DEPLOYMENT_ID in $DEPLOYMENTS; do
echo "Marking GitHub Deployment $DEPLOYMENT_ID as inactive"
curl -f -H "Authorization: token ${{ inputs.github-token }}" -X POST -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/$GITHUB_REPOSITORY/deployments/$DEPLOYMENT_ID/statuses -d "{\"state\":\"inactive\"}"
curl -H "Authorization: token ${{ inputs.github-token }}" -X DELETE -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/$GITHUB_REPOSITORY/environments/pantheon-$MULTIDEV
done
drainpipe_exec "terminus multidev:delete ${{ inputs.site-name }}.$MULTIDEV --delete-branch --yes"
else
"Dangling Multidev environment $MULTIDEV found, no action taken."
Expand Down

0 comments on commit 067f741

Please sign in to comment.