Merge pull request #41 from thecodingmachine/one_env_per_branch

Deploying one environment per branch
This commit is contained in:
David Négrier 2020-04-13 18:52:56 +02:00 committed by GitHub
commit 751a9f40e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 46 additions and 31 deletions

View File

@ -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

View File

@ -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"
}
}
}
}

24
deeployer.libsonnet Normal file
View File

@ -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"
}
}
}
}