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 01660ff
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 3 deletions.
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 }}"
6 changes: 3 additions & 3 deletions .github/workflows/test-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
name: Get deployments for this PR
runs-on: ubuntu-latest
outputs:
items: ${{ steps.list_deployments.outputs.data }}
items: ${{ fromJSON(steps.list_deployments.outputs.data) }}
steps:
- name: list deployments
id: list_deployments
Expand All @@ -24,13 +24,13 @@ jobs:
delete-old-deployments:
name: Inactivate deployment
runs-on: ubuntu-latest
if: ${{ github.event.action == 'closed' }}
if: steps.find-old-deployments.outputs.items[0] != null
needs:
- find-old-deployments
strategy:
fail-fast: false
matrix:
item: ${{ fromJSON(needs.find-old-deployments.outputs.items) }}
item: ${{ needs.find-old-deployments.outputs.items }}
steps:
- name: set deployments inactive
id: inactivate_deployments
Expand Down

0 comments on commit 01660ff

Please sign in to comment.