-
Notifications
You must be signed in to change notification settings - Fork 2
172 lines (159 loc) · 5.87 KB
/
docker-publish.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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
name: Docker
on: [push, pull_request]
jobs:
#build and publish image
Build-API-Image:
name: Build API image
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- uses: FranzDiebold/github-env-vars-action@v2
- uses: docker/setup-qemu-action@v2
- uses: docker/setup-buildx-action@v2
- name: Build API image with buildx
uses: docker/build-push-action@v3
with:
context: .
cache-from: type=gha
cache-to: type=gha,mode=max
Build-Frontend-Image:
name: Build Frontend image
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- uses: FranzDiebold/github-env-vars-action@v2
- uses: docker/setup-qemu-action@v2
- uses: docker/setup-buildx-action@v2
- name: Build frontend image
uses: docker/build-push-action@v3
with:
context: ./frontend
cache-from: type=gha
cache-to: type=gha,mode=max
Test-API-Image:
name: Test API image
runs-on: ubuntu-20.04
needs: Build-API-Image
steps:
- uses: actions/checkout@v3
- uses: FranzDiebold/github-env-vars-action@v2
- uses: docker/setup-qemu-action@v2
- uses: docker/setup-buildx-action@v2
- name: Build API image with buildx
uses: docker/build-push-action@v3
with:
context: .
tags: wycliffeassociates/doc:local
load: true
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Test API image with docker-compose
run: |
docker compose -f docker-compose.yml -f docker-compose.api-test.yml up --exit-code-from test-runner
Test-Frontend-Image:
name: Test Frontend image
runs-on: ubuntu-20.04
needs: [Build-API-Image, Build-Frontend-Image]
steps:
- uses: actions/checkout@v3
- uses: FranzDiebold/github-env-vars-action@v2
- uses: docker/setup-qemu-action@v2
- uses: docker/setup-buildx-action@v2
- name: Build api image
uses: docker/build-push-action@v3
with:
context: .
tags: wycliffeassociates/doc:local
load: true
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Build frontend image
uses: docker/build-push-action@v3
with:
context: ./frontend
tags: wycliffeassociates/doc-ui:local
load: true
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Build frontend-tests image
uses: docker/build-push-action@v3
with:
context: ./frontend
file: ./frontend/testsDockerfile
tags: wycliffeassociates/doc-ui-tests:local
load: true
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Test frontend image with docker-compose
run: docker compose -f docker-compose.yml -f docker-compose.frontend-test.yml up --exit-code-from frontend-test-runner
Push-Images:
name: Push images if this is a branch
runs-on: ubuntu-20.04
needs: [Test-API-Image, Test-Frontend-Image]
if: ${{ contains(fromJson('["push"]'), github.event_name) }}
steps:
- uses: actions/checkout@v3
- uses: FranzDiebold/github-env-vars-action@v2
- uses: docker/setup-qemu-action@v2
- uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USER }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}
- name: Set DOC docker tags
run: |
echo "DOC_TAG_SHA=wycliffeassociates/doc:$GITHUB_SHA" >> $GITHUB_ENV && \
echo "DOC_TAG_BRANCH=wycliffeassociates/doc:$CI_REF_NAME_SLUG" >> $GITHUB_ENV && \
echo "DOC_TAG_LATEST=wycliffeassociates/doc:latest" >> $GITHUB_ENV
- name: Set DOC-UI docker tags
run: |
echo "DOC_UI_TAG_SHA=wycliffeassociates/doc-ui:$GITHUB_SHA" >> $GITHUB_ENV && \
echo "DOC_UI_TAG_BRANCH=wycliffeassociates/doc-ui:$CI_REF_NAME_SLUG" >> $GITHUB_ENV && \
echo "DOC_UI_TAG_LATEST=wycliffeassociates/doc-ui:latest" >> $GITHUB_ENV
- name: Set version inside UI
run: |
PUBLIC_DOC_BUILD_TIMESTAMP=$(TZ='America/New_York' date +"%m-%d-%Y")
echo "PUBLIC_DOC_BUILD_TIMESTAMP=$PUBLIC_DOC_BUILD_TIMESTAMP" >> $GITHUB_ENV
echo "PUBLIC_DOC_VERSION=$CI_SHA_SHORT" >> $GITHUB_ENV
- name: Build and conditional push API image
uses: docker/build-push-action@v3
with:
context: .
push: true
tags: |
${{ env.DOC_TAG_SHA }}
${{ env.DOC_TAG_BRANCH }}
${{ env.DOC_TAG_LATEST }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Build and conditional push UI image
uses: docker/build-push-action@v3
with:
context: ./frontend
push: true
tags: |
${{ env.DOC_UI_TAG_SHA }}
${{ env.DOC_UI_TAG_BRANCH }}
${{ env.DOC_UI_TAG_LATEST }}
build-args: |
PUBLIC_DOC_VERSION_ARG=${{ env.PUBLIC_DOC_VERSION }}
PUBLIC_DOC_BUILD_TIMESTAMP_ARG=${{ env.PUBLIC_DOC_BUILD_TIMESTAMP }}
cache-from: type=gha
cache-to: type=gha,mode=max
Deploy-develop:
name: Develop deploy on successful develop build
needs: [Push-Images]
if: ${{ github.ref_name == 'doc-dev.walink.org' }}
runs-on: ubuntu-20.04
environment: doc-dev.walink.org
steps:
- name: Configure 1Password Service Account
uses: 1password/load-secrets-action@v1
with:
export-env: true
env:
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
DEV_DEPLOY_HOOK: op://DevOps/DEPLOY-doc-dev-walink-org-token/url
- name: Call Deploy Webhook
run: curl ${{ env.DEV_DEPLOY_HOOK }}