-
Notifications
You must be signed in to change notification settings - Fork 7
129 lines (116 loc) · 4.3 KB
/
cd-app.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
name: Déploiement de l'app
run-name: Déploiement de l'app sur ${{ github.event.inputs.target }}
on:
workflow_dispatch:
inputs:
target:
type: choice
description: Quel environnement ?
options:
- preprod
- staging
- prod
is-test-app:
type: boolean
description: Application de test
jobs:
build-app:
name: Build l'app
if: ${{ github.event.inputs.is-test-app != 'true' }}
environment: ${{ github.event.inputs.target }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: earthly/actions-setup@v1
with:
github-token: ${{ secrets.GH_TOKEN }}
version: ^0.8.0
- name: Login into registry
run: docker login ghcr.io/territoiresentransitions --username "${{ secrets.GH_USER }}" --password "${{ secrets.GH_TOKEN }}"
- name: Build and push app image
run: >
earthly
--use-inline-cache --save-inline-cache --push
--platform=linux/amd64
+app-docker
--ENV_NAME=${{ github.event.inputs.target }}
--ANON_KEY=${{ secrets.ANON_KEY }}
--API_URL=${{ secrets.API_URL }}
--AUTH_URL=${{ vars.AUTH_URL }}
--BACKEND_URL=${{ vars.BACKEND_URL }}
--PANIER_URL=${{ vars.PANIER_URL }}
--SENTRY_DSN=${{ vars.SENTRY_DSN }}
--CRISP_WEBSITE_ID=${{ vars.CRISP_WEBSITE_ID }}
--POSTHOG_HOST=${{ secrets.POSTHOG_HOST }}
--POSTHOG_KEY=${{ secrets.POSTHOG_KEY }}
build-test-app:
name: Build l'app de test # TODO: only on variable change, improve to avoid duplicate
if: ${{ github.event.inputs.is-test-app == 'true' }}
environment: ${{ github.event.inputs.target }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: earthly/actions-setup@v1
with:
github-token: ${{ secrets.GH_TOKEN }}
version: ^0.8.0
- name: Login into registry
run: docker login ghcr.io/territoiresentransitions --username "${{ secrets.GH_USER }}" --password "${{ secrets.GH_TOKEN }}"
- name: Build and push app test image
run: >
earthly
--use-inline-cache --save-inline-cache --push
--platform=linux/amd64
+app-test-docker
--ENV_NAME=${{ github.event.inputs.target }}
--ANON_KEY=${{ secrets.ANON_KEY }}
--API_URL=${{ secrets.API_URL }}
--AUTH_URL=${{ vars.AUTH_URL }}
--BACKEND_URL=${{ vars.BACKEND_TEST_URL }}
--PANIER_URL=${{ vars.PANIER_URL }}
--SENTRY_DSN=${{ vars.SENTRY_DSN }}
--CRISP_WEBSITE_ID=${{ vars.CRISP_WEBSITE_ID }}
--POSTHOG_HOST=${{ secrets.POSTHOG_HOST }}
--POSTHOG_KEY=${{ secrets.POSTHOG_KEY }}
deploy-app:
name: Déploie l'app
if: ${{ github.event.inputs.is-test-app != 'true' }}
needs: build-app
environment: ${{ github.event.inputs.target }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: earthly/actions-setup@v1
with:
github-token: ${{ secrets.GH_TOKEN }}
version: ^0.8.0
- name: Login into registry
run: docker login ghcr.io/territoiresentransitions --username "${{ secrets.GH_USER }}" --password "${{ secrets.GH_TOKEN }}"
- name: Deploy app on Koyeb
run: >
earthly
--use-inline-cache --save-inline-cache
+app-deploy
--ENV_NAME=${{ github.event.inputs.target }}
--KOYEB_API_KEY=${{ secrets.KOYEB_API_KEY }}
deploy-test-app:
name: Déploie l'app de test
if: ${{ github.event.inputs.is-test-app == 'true' }}
needs: build-test-app
environment: preprod-koyeb
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: earthly/actions-setup@v1
with:
github-token: ${{ secrets.GH_TOKEN }}
version: ^0.8.0
- name: Login into registry
run: docker login ghcr.io/territoiresentransitions --username "${{ secrets.GH_USER }}" --password "${{ secrets.GH_TOKEN }}"
- name: Deploy test app on Koyeb
run: >
earthly
--use-inline-cache --save-inline-cache
+app-deploy-test
--ENV_NAME=${{ github.event.inputs.target }}
--KOYEB_API_KEY=${{ secrets.KOYEB_API_KEY }}