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 0056d85
Show file tree
Hide file tree
Showing 2 changed files with 40 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/[email protected]
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/[email protected]
with:
route: DELETE /repos/:repository/deployments/:deployment_id
repository: ${{ github.repository }}
deployment_id: ${{ matrix.item.id }}
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
1 change: 0 additions & 1 deletion .github/workflows/test-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ jobs:
delete-old-deployments:
name: Inactivate deployment
runs-on: ubuntu-latest
if: ${{ github.event.action == 'closed' }}
needs:
- find-old-deployments
strategy:
Expand Down

0 comments on commit 0056d85

Please sign in to comment.