This repository has been archived by the owner on Nov 10, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
96 lines (90 loc) · 3.53 KB
/
deploy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
name: deploy frontend
on:
push:
branches:
- master
release:
types: [created]
env:
IMAGE_NAME: wesleyklop/journali-frontend/journali-frontend
REGISTRY_HOST: docker.pkg.github.com
STAGING_URL: http://staging.journali.nl
STAGING_SERVICE: journali-staging_web
PRODUCTION_URL: http://journali.nl
PRODUCTION_SERVICE: journali-production_web
jobs:
deliver:
runs-on: self-hosted
outputs:
image: ${{ env.REGISTRY_HOST }}/${{ env.IMAGE_NAME }}:${{ steps.publish.outputs.tag }}
steps:
- uses: actions/checkout@v2
- name: publish frontend docker image
id: publish
uses: elgohr/Publish-Docker-Github-Action@master
env:
VUE_APP_VERSION: ${{ github.sha }}
with:
name: ${{ env.IMAGE_NAME }}
username: ${{ github.actor }}
password: ${{ github.token }}
registry: ${{ env.REGISTRY_HOST }}
tag_semver: true
buildargs: VUE_APP_VERSION
deploy:
name: deploy to an environment
runs-on: self-hosted
needs: [deliver]
steps:
- name: set environment variables if staging
if: ${{ github.event_name == 'push' }}
uses: allenevans/[email protected]
with:
SERVICE: ${{ env.STAGING_SERVICE }}
URL: ${{ env.STAGING_URL }}
ENV_NAME: staging
- name: set environment variables if production
if: ${{ github.event_name == 'release' }}
uses: allenevans/[email protected]
with:
SERVICE: ${{ env.PRODUCTION_SERVICE }}
URL: ${{ env.PRODUCTION_URL }}
ENV_NAME: production
- name: login to registry
run: echo ${{ github.token }} | docker login ${{ env.REGISTRY_HOST }} -u ${{ github.actor }} --password-stdin
- name: start deployment
uses: bobheadxi/deployments@master
id: deployment
with:
step: start
token: ${{ github.token }}
env: ${{ env.ENV_NAME }}
# Deploy new frontend version
- name: deploy new frontend version
run: |
docker service update \
--update-failure-action=rollback \
--with-registry-auth \
--image ${{ needs.deliver.outputs.image }} \
--force \
${{ env.SERVICE }}
- name: update deployment status
uses: bobheadxi/deployments@master
if: always()
with:
step: finish
token: ${{ github.token }}
status: ${{ job.status }}
env_url: ${{ env.URL }}
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
desc: image ${{ needs.deliver.outputs.image }}
- name: Actions for Discord
if: always()
uses: Ilshidur/[email protected]
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
with:
args: Frontend deployed with ${{ job.status }} to ${{ env.ENV_NAME }} with image ${{ needs.deliver.outputs.image }}!
- name: logout from registry
if: always()
run: docker logout ${{ env.REGISTRY_HOST }}