Merge pull request #41 from thecodingmachine/one_env_per_branch
Deploying one environment per branch
This commit is contained in:
commit
751a9f40e5
32
.github/workflows/build-and-deploy.yml
vendored
32
.github/workflows/build-and-deploy.yml
vendored
@ -1,12 +1,7 @@
|
|||||||
name: Build, push and deploy Docker image
|
name: Build, push and deploy Docker image
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
- push
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
- cd
|
|
||||||
# tags:
|
|
||||||
# - '*'
|
|
||||||
|
|
||||||
# Enables BuildKit
|
# Enables BuildKit
|
||||||
env:
|
env:
|
||||||
@ -23,6 +18,10 @@ jobs:
|
|||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
|
||||||
|
# Create a slugified value of the branch
|
||||||
|
- uses: rlespinasse/github-slug-action@master
|
||||||
|
|
||||||
- name: "Build and push front image"
|
- name: "Build and push front image"
|
||||||
uses: docker/build-push-action@v1
|
uses: docker/build-push-action@v1
|
||||||
with:
|
with:
|
||||||
@ -31,7 +30,7 @@ jobs:
|
|||||||
username: ${{ secrets.DOCKER_USERNAME }}
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
repository: thecodingmachine/workadventure-front
|
repository: thecodingmachine/workadventure-front
|
||||||
tag_with_ref: true
|
tags: ${{ env.GITHUB_REF_SLUG }}
|
||||||
add_git_labels: true
|
add_git_labels: true
|
||||||
|
|
||||||
build-back:
|
build-back:
|
||||||
@ -43,6 +42,9 @@ jobs:
|
|||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
# Create a slugified value of the branch
|
||||||
|
- uses: rlespinasse/github-slug-action@master
|
||||||
|
|
||||||
- name: "Build and push back image"
|
- name: "Build and push back image"
|
||||||
uses: docker/build-push-action@v1
|
uses: docker/build-push-action@v1
|
||||||
with:
|
with:
|
||||||
@ -51,7 +53,7 @@ jobs:
|
|||||||
username: ${{ secrets.DOCKER_USERNAME }}
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
repository: thecodingmachine/workadventure-back
|
repository: thecodingmachine/workadventure-back
|
||||||
tag_with_ref: true
|
tags: ${{ env.GITHUB_REF_SLUG }}
|
||||||
add_git_labels: true
|
add_git_labels: true
|
||||||
|
|
||||||
deeploy:
|
deeploy:
|
||||||
@ -64,10 +66,20 @@ jobs:
|
|||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
# Create a slugified value of the branch
|
||||||
|
- uses: rlespinasse/github-slug-action@1.1.0
|
||||||
|
|
||||||
- name: Deploy
|
- name: Deploy
|
||||||
uses: thecodingmachine/deeployer@master
|
uses: thecodingmachine/deeployer@master
|
||||||
env:
|
env:
|
||||||
KUBE_CONFIG_FILE: ${{ secrets.KUBE_CONFIG_FILE }}
|
KUBE_CONFIG_FILE: ${{ secrets.KUBE_CONFIG_FILE }}
|
||||||
AUTOCONNECT: 1
|
|
||||||
with:
|
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
|
||||||
|
@ -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
24
deeployer.libsonnet
Normal 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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user