diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index 607e6ae7..2b003230 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -1,12 +1,7 @@ name: Build, push and deploy Docker image on: - push: - branches: - - master - - cd -# tags: -# - '*' + - push # Enables BuildKit env: @@ -23,6 +18,10 @@ jobs: - name: Checkout uses: actions/checkout@v2 + + # Create a slugified value of the branch + - uses: rlespinasse/github-slug-action@master + - name: "Build and push front image" uses: docker/build-push-action@v1 with: @@ -31,7 +30,7 @@ jobs: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} repository: thecodingmachine/workadventure-front - tag_with_ref: true + tags: ${{ env.GITHUB_REF_SLUG }} add_git_labels: true build-back: @@ -43,6 +42,9 @@ jobs: - name: Checkout uses: actions/checkout@v2 + # Create a slugified value of the branch + - uses: rlespinasse/github-slug-action@master + - name: "Build and push back image" uses: docker/build-push-action@v1 with: @@ -51,7 +53,7 @@ jobs: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} repository: thecodingmachine/workadventure-back - tag_with_ref: true + tags: ${{ env.GITHUB_REF_SLUG }} add_git_labels: true deeploy: @@ -64,10 +66,20 @@ jobs: - name: Checkout uses: actions/checkout@v2 + # Create a slugified value of the branch + - uses: rlespinasse/github-slug-action@1.1.0 + - name: Deploy uses: thecodingmachine/deeployer@master env: KUBE_CONFIG_FILE: ${{ secrets.KUBE_CONFIG_FILE }} - AUTOCONNECT: 1 with: - namespace: workadventure-master + namespace: workadventure-${{ env.GITHUB_REF_SLUG }} + + - name: Add a comment in PR + uses: unsplash/comment-on-pr@v1.2.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + msg: Environment deployed at http://${{ env.GITHUB_REF_SLUG }}.workadventure.test.thecodingmachine.com + check_for_duplicate_msg: true diff --git a/deeployer.json b/deeployer.json deleted file mode 100644 index 930e6f37..00000000 --- a/deeployer.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "$schema": "https://raw.githubusercontent.com/thecodingmachine/deeployer/master/deeployer.schema.json", - "containers": { - "back": { - "image": "thecodingmachine/workadventure-back:cd", - "host": "api.workadventure.test.thecodingmachine.com", - "ports": [8080], - "env": { - "SECRET_KEY": "tempSecretKeyNeedsToChange" - } - }, - "front": { - "image": "thecodingmachine/workadventure-front:cd", - "host": "workadventure.test.thecodingmachine.com", - "ports": [80], - "env": { - "API_URL": "http://api.workadventure.test.thecodingmachine.com" - } - } - } -} diff --git a/deeployer.libsonnet b/deeployer.libsonnet new file mode 100644 index 00000000..4e44db34 --- /dev/null +++ b/deeployer.libsonnet @@ -0,0 +1,24 @@ +{ + local env = std.extVar("env"), + local namespace = env.GITHUB_REF_SLUG, + local tag = if namespace == "master" then "latest" else namespace, + "$schema": "https://raw.githubusercontent.com/thecodingmachine/deeployer/master/deeployer.schema.json", + "containers": { + "back": { + "image": "thecodingmachine/workadventure-back:"+tag, + "host": "api."+namespace+".workadventure.test.thecodingmachine.com", + "ports": [8080], + "env": { + "SECRET_KEY": "tempSecretKeyNeedsToChange" + } + }, + "front": { + "image": "thecodingmachine/workadventure-front:"+tag, + "host": namespace+".workadventure.test.thecodingmachine.com", + "ports": [80], + "env": { + "API_URL": "http://api."+namespace+".workadventure.test.thecodingmachine.com" + } + } + } +}