2020-04-09 11:00:30 +02:00
name : Build, push and deploy Docker image
on :
2021-05-10 11:56:08 +02:00
push :
2021-06-03 18:34:55 +02:00
branches : [ master, develop]
2021-04-29 14:44:41 +02:00
release :
2021-04-29 18:44:46 +02:00
types : [ created]
2021-04-26 15:14:21 +02:00
pull_request :
2022-03-08 11:21:17 +01:00
types : [ labeled, synchronize]
2020-04-09 11:00:30 +02:00
jobs :
build-front :
2021-05-10 12:10:47 +02:00
if : ${{ github.event_name == 'push' || github.event_name == 'release' || github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'deploy') }}
2020-04-09 11:00:30 +02:00
runs-on : ubuntu-latest
steps :
- name : Checkout
uses : actions/checkout@v2
2022-03-08 11:21:17 +01:00
- name : Setup NodeJS
uses : actions/setup-node@v2
with :
node-version : '14'
2020-04-13 18:15:27 +02:00
2022-03-08 11:21:17 +01:00
# messages
- name : Install messages dependencies
run : yarn install
working-directory : messages
- name : Build proto messages
run : yarn run ts-proto && yarn run copy-to-front-ts-proto && yarn run json-copy-to-front
working-directory : messages
2020-04-13 18:15:27 +02:00
2022-03-08 11:21:17 +01:00
# docker
- name : Set up QEMU
uses : docker/setup-qemu-action@v1
- name : Set up Docker Buildx
uses : docker/setup-buildx-action@v1
- name : Login to DockerHub
uses : docker/login-action@v1
2020-04-09 11:00:30 +02:00
with :
username : ${{ secrets.DOCKER_USERNAME }}
password : ${{ secrets.DOCKER_PASSWORD }}
2022-03-08 11:21:17 +01:00
- uses : rlespinasse/github-slug-action@3.1.0
- name : Docker meta
id : meta
uses : docker/metadata-action@v3
with :
images : thecodingmachine/workadventure-front
- name : Build and push
uses : docker/build-push-action@v2
with :
context : .
file : front/Dockerfile
platforms : linux/amd64,linux/arm64
push : true
tags : thecodingmachine/workadventure-front:${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
labels : ${{ steps.meta.outputs.labels }}
2020-04-09 11:00:30 +02:00
build-back :
2021-05-10 12:10:47 +02:00
if : ${{ github.event_name == 'push' || github.event_name == 'release' || github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'deploy') }}
2020-04-09 11:00:30 +02:00
runs-on : ubuntu-latest
steps :
- name : Checkout
uses : actions/checkout@v2
2022-03-08 11:21:17 +01:00
- name : Setup NodeJS
uses : actions/setup-node@v2
with :
node-version : '14'
# messages
- name : Install messages dependencies
run : yarn install
working-directory : messages
- name : Build proto messages
2022-03-11 17:02:58 +01:00
run : yarn run proto && yarn run copy-to-back && yarn run json-copy-to-back
2022-03-08 11:21:17 +01:00
working-directory : messages
# docker
- name : Set up QEMU
uses : docker/setup-qemu-action@v1
- name : Set up Docker Buildx
uses : docker/setup-buildx-action@v1
2020-12-04 15:13:35 +01:00
2022-03-08 11:21:17 +01:00
- name : Login to DockerHub
uses : docker/login-action@v1
2020-12-04 15:13:35 +01:00
with :
username : ${{ secrets.DOCKER_USERNAME }}
password : ${{ secrets.DOCKER_PASSWORD }}
2022-03-08 11:21:17 +01:00
- uses : rlespinasse/github-slug-action@3.1.0
- name : Docker meta
id : meta
uses : docker/metadata-action@v3
with :
images : thecodingmachine/workadventure-back
- name : Build and push
uses : docker/build-push-action@v2
with :
context : .
file : back/Dockerfile
platforms : linux/amd64,linux/arm64
push : true
tags : thecodingmachine/workadventure-back:${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
labels : ${{ steps.meta.outputs.labels }}
2020-12-04 15:13:35 +01:00
build-pusher :
2021-05-10 12:10:47 +02:00
if : ${{ github.event_name == 'push' || github.event_name == 'release' || github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'deploy') }}
2020-12-04 15:13:35 +01:00
runs-on : ubuntu-latest
steps :
- name : Checkout
uses : actions/checkout@v2
2022-03-08 11:21:17 +01:00
- name : Setup NodeJS
uses : actions/setup-node@v2
with :
node-version : '14'
# messages
- name : Install messages dependencies
run : yarn install
working-directory : messages
- name : Build proto messages
run : yarn run proto && yarn run copy-to-pusher && yarn run json-copy-to-pusher
working-directory : messages
2020-04-13 18:15:27 +02:00
2022-03-08 11:21:17 +01:00
# docker
- name : Set up QEMU
uses : docker/setup-qemu-action@v1
- name : Set up Docker Buildx
uses : docker/setup-buildx-action@v1
- name : Login to DockerHub
uses : docker/login-action@v1
2020-04-09 11:00:30 +02:00
with :
username : ${{ secrets.DOCKER_USERNAME }}
password : ${{ secrets.DOCKER_PASSWORD }}
2022-03-08 11:21:17 +01:00
- uses : rlespinasse/github-slug-action@3.1.0
- name : Docker meta
id : meta
uses : docker/metadata-action@v3
with :
images : thecodingmachine/workadventure-pusher
- name : Build and push
uses : docker/build-push-action@v2
with :
context : .
file : pusher/Dockerfile
platforms : linux/amd64,linux/arm64
push : true
tags : thecodingmachine/workadventure-pusher:${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
labels : ${{ steps.meta.outputs.labels }}
2020-06-01 16:12:48 +02:00
2020-12-09 21:29:29 +01:00
build-uploader :
2021-05-10 12:10:47 +02:00
if : ${{ github.event_name == 'push' || github.event_name == 'release' || github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'deploy') }}
2020-12-09 21:29:29 +01:00
runs-on : ubuntu-latest
steps :
2022-03-08 11:21:17 +01:00
- name : Set up QEMU
uses : docker/setup-qemu-action@v1
2020-12-09 21:29:29 +01:00
2022-03-08 11:21:17 +01:00
- name : Set up Docker Buildx
uses : docker/setup-buildx-action@v1
2020-12-09 21:29:29 +01:00
2022-03-08 11:21:17 +01:00
- name : Login to DockerHub
uses : docker/login-action@v1
2020-12-09 21:29:29 +01:00
with :
username : ${{ secrets.DOCKER_USERNAME }}
password : ${{ secrets.DOCKER_PASSWORD }}
2022-03-08 11:21:17 +01:00
- uses : rlespinasse/github-slug-action@3.1.0
- name : Docker meta
id : meta
uses : docker/metadata-action@v3
with :
images : thecodingmachine/workadventure-uploader
- name : Build and push
uses : docker/build-push-action@v2
with :
file : uploader/Dockerfile
push : true
tags : thecodingmachine/workadventure-uploader:${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
labels : ${{ steps.meta.outputs.labels }}
2020-12-09 21:29:29 +01:00
2020-07-23 18:43:51 +02:00
build-maps :
2021-05-10 12:10:47 +02:00
if : ${{ github.event_name == 'push' || github.event_name == 'release' || github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'deploy') }}
2020-07-23 18:43:51 +02:00
runs-on : ubuntu-latest
steps :
- name : Checkout
uses : actions/checkout@v2
2022-03-08 11:21:17 +01:00
- name : Set up QEMU
uses : docker/setup-qemu-action@v1
2020-07-23 18:43:51 +02:00
2022-03-08 11:21:17 +01:00
- name : Set up Docker Buildx
uses : docker/setup-buildx-action@v1
2020-07-23 18:43:51 +02:00
2022-03-08 11:21:17 +01:00
- name : Login to DockerHub
uses : docker/login-action@v1
2020-07-23 18:43:51 +02:00
with :
username : ${{ secrets.DOCKER_USERNAME }}
password : ${{ secrets.DOCKER_PASSWORD }}
2022-03-08 11:21:17 +01:00
- uses : rlespinasse/github-slug-action@3.1.0
- name : Docker meta
id : meta
uses : docker/metadata-action@v3
with :
images : thecodingmachine/workadventure-maps
- name : Build and push
uses : docker/build-push-action@v2
with :
context : maps/
file : maps/Dockerfile
push : true
tags : thecodingmachine/workadventure-maps:${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
labels : ${{ steps.meta.outputs.labels }}
2020-04-09 11:00:30 +02:00
deeploy :
needs :
- build-front
- build-back
2020-12-11 12:37:11 +01:00
- build-pusher
- build-maps
- build-uploader
2020-04-09 11:00:30 +02:00
runs-on : ubuntu-latest
2021-05-10 12:10:47 +02:00
if : ${{ github.event_name == 'push' || github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'deploy') }}
2020-04-09 11:00:30 +02:00
2020-04-09 11:03:24 +02:00
steps :
2020-04-09 11:00:30 +02:00
- name : Checkout
uses : actions/checkout@v2
2020-04-13 15:44:33 +02:00
# Create a slugified value of the branch
2020-12-09 13:50:18 +01:00
- uses : rlespinasse/github-slug-action@3.1.0
2020-04-13 15:44:33 +02:00
2022-02-17 15:04:51 +01:00
- name : Set ADMIN_URL if "deploy-connect-to-admin" label is set
run : echo "ADMIN_API_URL=https://${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}.test.workadventu.re" >> $GITHUB_ENV
if : ${{ github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'deploy-connect-to-admin') }}
2021-06-11 11:57:27 +02:00
- name : Write certificate
2021-06-11 14:25:02 +02:00
run : echo "${CERTS_PRIVATE_KEY}" > secret.key && chmod 0600 secret.key
2021-06-11 11:57:27 +02:00
env :
CERTS_PRIVATE_KEY : ${{ secrets.CERTS_PRIVATE_KEY }}
- name : Download certificate
2021-06-11 14:44:23 +02:00
run : mkdir secrets && scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i secret.key ubuntu@cert.workadventu.re:./config/live/workadventu.re/* secrets/
2021-06-11 11:57:27 +02:00
2021-06-11 14:52:59 +02:00
- name : Create namespace
uses : steebchen/kubectl@v1.0.0
env :
KUBE_CONFIG_DATA : ${{ secrets.KUBE_CONFIG_FILE_BASE64 }}
with :
args : create namespace workadventure-${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
continue-on-error : true
2021-06-11 15:31:27 +02:00
- name : Delete old certificates in namespace
uses : steebchen/kubectl@v1.0.0
env :
KUBE_CONFIG_DATA : ${{ secrets.KUBE_CONFIG_FILE_BASE64 }}
with :
args : -n workadventure-${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }} delete secret certificate-tls
continue-on-error : true
2021-06-11 11:57:27 +02:00
- name : Install certificates in namespace
uses : steebchen/kubectl@v1.0.0
env :
2021-06-11 14:37:43 +02:00
KUBE_CONFIG_DATA : ${{ secrets.KUBE_CONFIG_FILE_BASE64 }}
2021-06-11 11:57:27 +02:00
with :
args : -n workadventure-${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }} create secret tls certificate-tls --key="secrets/privkey.pem" --cert="secrets/fullchain.pem"
2020-04-09 12:14:06 +02:00
- name : Deploy
2020-12-18 17:04:31 +01:00
uses : thecodingmachine/deeployer-action@master
2020-04-09 14:21:43 +02:00
env :
KUBE_CONFIG_FILE : ${{ secrets.KUBE_CONFIG_FILE }}
2020-10-14 12:25:05 +02:00
ADMIN_API_TOKEN : ${{ secrets.ADMIN_API_TOKEN }}
2022-02-17 15:34:00 +01:00
ADMIN_SOCKETS_TOKEN : ${{ secrets.ADMIN_SOCKETS_TOKEN }}
2020-10-19 12:07:05 +02:00
JITSI_ISS : ${{ secrets.JITSI_ISS }}
JITSI_URL : ${{ secrets.JITSI_URL }}
SECRET_JITSI_KEY : ${{ secrets.SECRET_JITSI_KEY }}
2021-02-16 11:34:12 +01:00
TURN_STATIC_AUTH_SECRET : ${{ secrets.TURN_STATIC_AUTH_SECRET }}
2021-05-10 12:10:47 +02:00
DEPLOY_REF : ${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
2021-09-16 17:03:49 +02:00
POSTHOG_API_KEY : ${{ secrets.POSTHOG_API_KEY }}
POSTHOG_URL : ${{ secrets.POSTHOG_URL }}
2020-04-09 12:14:06 +02:00
with :
2021-05-10 12:10:47 +02:00
namespace : workadventure-${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
2020-04-13 18:30:22 +02:00
- name : Add a comment in PR
2020-04-13 18:33:27 +02:00
uses : unsplash/comment-on-pr@v1.2.0
2021-05-10 12:10:47 +02:00
if : ${{ github.event_name == 'pull_request' }}
2020-04-13 18:30:22 +02:00
env :
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
with :
2021-06-28 13:54:49 +02:00
msg : "Environment deployed at https://play-${{ env.GITHUB_HEAD_REF_SLUG }}.test.workadventu.re \nTests available at https://maps-${{ env.GITHUB_HEAD_REF_SLUG }}.test.workadventu.re/tests"