From 7bd524ba5563d7a6c6236e16838792fcb0efe7c8 Mon Sep 17 00:00:00 2001 From: kharhamel Date: Thu, 29 Apr 2021 14:44:41 +0200 Subject: [PATCH] FIX: fixed the deploy workflow to also build images on new releases --- .github/workflows/build-and-deploy.yml | 25 ++++++++++++++----------- .github/workflows/cleanup.yml | 1 + deeployer.libsonnet | 2 +- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index 5c09de3e..7de6a8b3 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -1,6 +1,8 @@ name: Build, push and deploy Docker image on: + release: + types: [released] pull_request: types: [ labeled, synchronize ] @@ -12,7 +14,7 @@ env: jobs: build-front: - if: ${{ contains(github.event.pull_request.labels.*.name, 'deploy') }} + if: ${{ github.event.release || contains(github.event.pull_request.labels.*.name, 'deploy') }} runs-on: ubuntu-latest steps: @@ -32,11 +34,11 @@ jobs: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} repository: thecodingmachine/workadventure-front - tags: ${{ env.GITHUB_HEAD_REF_SLUG }} + tags: ${{ github.event.pull_request && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF }} add_git_labels: true build-back: - if: ${{ contains(github.event.pull_request.labels.*.name, 'deploy') }} + if: ${{ github.event.release || contains(github.event.pull_request.labels.*.name, 'deploy') }} runs-on: ubuntu-latest steps: @@ -55,11 +57,11 @@ jobs: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} repository: thecodingmachine/workadventure-back - tags: ${{ env.GITHUB_HEAD_REF_SLUG }} + tags: ${{ github.event.pull_request && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF }} add_git_labels: true build-pusher: - if: ${{ contains(github.event.pull_request.labels.*.name, 'deploy') }} + if: ${{ github.event.release || contains(github.event.pull_request.labels.*.name, 'deploy') }} runs-on: ubuntu-latest steps: @@ -78,11 +80,11 @@ jobs: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} repository: thecodingmachine/workadventure-pusher - tags: ${{ env.GITHUB_HEAD_REF_SLUG }} + tags: ${{ github.event.pull_request && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF }} add_git_labels: true build-uploader: - if: ${{ contains(github.event.pull_request.labels.*.name, 'deploy') }} + if: ${{ github.event.release || contains(github.event.pull_request.labels.*.name, 'deploy') }} runs-on: ubuntu-latest steps: @@ -101,11 +103,11 @@ jobs: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} repository: thecodingmachine/workadventure-uploader - tags: ${{ env.GITHUB_HEAD_REF_SLUG }} + tags: ${{ github.event.pull_request && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF }} add_git_labels: true build-maps: - if: ${{ contains(github.event.pull_request.labels.*.name, 'deploy') }} + if: ${{ github.event.release || contains(github.event.pull_request.labels.*.name, 'deploy') }} runs-on: ubuntu-latest steps: @@ -125,7 +127,7 @@ jobs: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} repository: thecodingmachine/workadventure-maps - tags: ${{ env.GITHUB_HEAD_REF_SLUG }} + tags: ${{ github.event.pull_request && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF }} add_git_labels: true deeploy: @@ -136,6 +138,7 @@ jobs: - build-maps - build-uploader runs-on: ubuntu-latest + if: ${{ contains(github.event.pull_request.labels.*.name, 'deploy') }} steps: - name: Checkout @@ -153,12 +156,12 @@ jobs: JITSI_URL: ${{ secrets.JITSI_URL }} SECRET_JITSI_KEY: ${{ secrets.SECRET_JITSI_KEY }} TURN_STATIC_AUTH_SECRET: ${{ secrets.TURN_STATIC_AUTH_SECRET }} + DEPLOY_REF: ${{ env.GITHUB_HEAD_REF_SLUG }} with: namespace: workadventure-${{ env.GITHUB_HEAD_REF_SLUG }} - name: Add a comment in PR uses: unsplash/comment-on-pr@v1.2.0 - if: ${{ env.GITHUB_HEAD_REF_SLUG != 'master' }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: diff --git a/.github/workflows/cleanup.yml b/.github/workflows/cleanup.yml index ab39978b..ffa8273f 100644 --- a/.github/workflows/cleanup.yml +++ b/.github/workflows/cleanup.yml @@ -18,6 +18,7 @@ jobs: - uses: rlespinasse/github-slug-action@3.1.0 - name: Cleanup + continue-on-error: true uses: thecodingmachine/deeployer-cleanup-action@master env: KUBE_CONFIG_FILE: ${{ secrets.KUBE_CONFIG_FILE }} diff --git a/deeployer.libsonnet b/deeployer.libsonnet index f94f4e69..7ed9db8c 100644 --- a/deeployer.libsonnet +++ b/deeployer.libsonnet @@ -1,6 +1,6 @@ { local env = std.extVar("env"), - local namespace = env.GITHUB_HEAD_REF_SLUG, + local namespace = env.DEPLOY_REF, local tag = namespace, local url = if namespace == "master" then "workadventu.re" else namespace+".test.workadventu.re", // develop branch does not use admin because of issue with SSL certificate of admin as of now.