From 14a081133ad1b88226566d0492b14d60dd17c768 Mon Sep 17 00:00:00 2001 From: spyridon chortis <86228064+spchortis@users.noreply.github.com> Date: Thu, 31 Aug 2023 14:55:24 +0100 Subject: [PATCH] chore: Application is not deleted if the branch is deleted on merge (#96) --- assets/github/onbranch.tmpl | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/assets/github/onbranch.tmpl b/assets/github/onbranch.tmpl index 1ead18c..2ab3a7b 100644 --- a/assets/github/onbranch.tmpl +++ b/assets/github/onbranch.tmpl @@ -7,6 +7,7 @@ on: jobs: on_pr: + if: github.event.action != 'closed' concurrency: {{ `${{ github.head_ref }}` }} runs-on: ubuntu-latest steps: @@ -14,11 +15,10 @@ jobs: with: ref: {{ `${{ github.head_ref }}` }} - - name: delete application - if: github.event.action == 'closed' + - name: build and deploy application uses: docker://ghcr.io/nearform/initium-cli:latest with: - args: onbranch --clean + args: onbranch env: INITIUM_REGISTRY_USER: {{ `${{ github.actor }}` }} INITIUM_REGISTRY_PASSWORD: {{ `${{ secrets.GITHUB_TOKEN }}` }} @@ -26,14 +26,20 @@ jobs: INITIUM_CLUSTER_TOKEN: {{ `${{ secrets.CLUSTER_TOKEN }}` }} INITIUM_CLUSTER_CA_CERT: {{ `${{ secrets.CLUSTER_CA_CERT }}` }} - - name: build and deploy application - if: github.event.action != 'closed' + closed_pr: + if: github.event.action == 'closed' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: delete application uses: docker://ghcr.io/nearform/initium-cli:latest with: - args: onbranch + args: onbranch --clean --branch-name {{ `${{ github.head_ref }}` }} env: INITIUM_REGISTRY_USER: {{ `${{ github.actor }}` }} INITIUM_REGISTRY_PASSWORD: {{ `${{ secrets.GITHUB_TOKEN }}` }} INITIUM_CLUSTER_ENDPOINT: {{ `${{ secrets.CLUSTER_ENDPOINT }}` }} INITIUM_CLUSTER_TOKEN: {{ `${{ secrets.CLUSTER_TOKEN }}` }} INITIUM_CLUSTER_CA_CERT: {{ `${{ secrets.CLUSTER_CA_CERT }}` }} +