From 0056d85ad40abceb67bf133943a8358175c8dc92 Mon Sep 17 00:00:00 2001 From: Manuel Meister Date: Fri, 15 Apr 2022 18:46:23 +0200 Subject: [PATCH] Add command to delete deployments --- .github/workflows/delete_deployments.yaml | 40 +++++++++++++++++++++++ .github/workflows/test-deploy.yaml | 1 - 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/delete_deployments.yaml diff --git a/.github/workflows/delete_deployments.yaml b/.github/workflows/delete_deployments.yaml new file mode 100644 index 0000000..e153327 --- /dev/null +++ b/.github/workflows/delete_deployments.yaml @@ -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 }}" \ No newline at end of file diff --git a/.github/workflows/test-deploy.yaml b/.github/workflows/test-deploy.yaml index ebd3c74..4210a53 100644 --- a/.github/workflows/test-deploy.yaml +++ b/.github/workflows/test-deploy.yaml @@ -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: