From 0feb1b958a04b0c0fcbe0373572ecea599070763 Mon Sep 17 00:00:00 2001 From: Matthew R Kasun Date: Wed, 29 Mar 2023 13:56:34 -0400 Subject: [PATCH] delete droplets on completion of tests --- .github/workflows/deletedroplets.yml | 38 ++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 .github/workflows/deletedroplets.yml diff --git a/.github/workflows/deletedroplets.yml b/.github/workflows/deletedroplets.yml new file mode 100644 index 00000000..3820fcc6 --- /dev/null +++ b/.github/workflows/deletedroplets.yml @@ -0,0 +1,38 @@ +name: Delete Droplets + +on: + workflows_run: + workflows: [Run All Test on Branch] + types: + - completed + +jobs: + on-success: + runs-on: ubuntu-latest + if: ${{ github.event.workflow_run.conclusion == 'success' }} + steps: + - name: delete droplets + run: | + sleep 15m + curl -X GET \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \ + "https://api.digitalocean.com/v2/droplets?tag_name=$TAG" + env: + DIGITALOCEAN_TOKEN: ${{ secrets.DIGITALOCEAN_TOKEN }} + TAG: ${{ github.event.workflow_run.run_id }}-${{ github.event.workflow_run.run_attempt }} + + on-failure: + runs-on: ubuntu-latest + if: ${{ github.event.workflow_run.conclusion == 'failure' }} + steps: + - name: delete droplets + run: | + sleep 6h + curl -X GET \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \ + "https://api.digitalocean.com/v2/droplets?tag_name=$TAG" + env: + DIGITALOCEAN_TOKEN: ${{ secrets.DIGITALOCEAN_TOKEN }} + TAG: ${{ github.event.workflow_run.run_id }}-${{ github.event.workflow_run.run_attempt }}