Skip to content

Commit

Permalink
Add command to delete deployments
Browse files Browse the repository at this point in the history
  • Loading branch information
manuelmeister committed Apr 15, 2022
1 parent e16f444 commit 00b5d66
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
40 changes: 40 additions & 0 deletions .github/workflows/delete_deployments.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Delete Deployments

on:
workflow_dispatch:

jobs:
find-old-deployments:
name: Get deployments for this PR
runs-on: ubuntu-latest
outputs:
items: ${{ steps.list_deployments.outputs.data }}
steps:
- name: list deployments
id: list_deployments
uses: octokit/request-action@v2.x
with:
route: GET /repos/:repository/deployments
repository: ${{ github.repository }}
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

delete-old-deployments:
name: Inactivate deployment
runs-on: ubuntu-latest
needs:
- find-old-deployments
strategy:
fail-fast: false
matrix:
item: ${{ fromJSON(needs.find-old-deployments.outputs.items) }}
steps:
- name: set deployments inactive
id: inactivate_deployments
uses: octokit/request-action@v2.x
with:
route: DELETE /repos/:repository/deployments/:deployment_id
repository: ${{ github.repository }}
deployment_id: ${{ matrix.item.id }}
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
2 changes: 1 addition & 1 deletion .github/workflows/test-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ jobs:
delete-old-deployments:
name: Inactivate deployment
runs-on: ubuntu-latest
if: ${{ github.event.action == 'closed' }}
needs:
- find-old-deployments
if: needs.find-old-deployments.outputs.items[0] != null
strategy:
fail-fast: false
matrix:
Expand Down

0 comments on commit 00b5d66

Please sign in to comment.