-
Notifications
You must be signed in to change notification settings - Fork 0
185 lines (163 loc) · 6.02 KB
/
ci-and-cd.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
173
174
175
176
177
178
179
180
181
182
183
184
185
name: CI & CD
on:
# Trigger the workflow on push or pull request,
# but only for the main branch
push:
branches:
- main
pull_request:
branches:
- main
release:
types:
- published
env:
# Configures docker-compose to use Docker CLI to build the image:
COMPOSE_DOCKER_CLI_BUILD: 1
# Configures Docker CLI to use BuildKit to build the image:
DOCKER_BUILDKIT: 1
# The workspace directory used by ci-compose:
PWD: ${{ github.workspace }}
jobs:
test_build:
name: Build Testing Image
runs-on: ubuntu-latest
outputs:
build-uuid: ${{ steps.uuidgen.outputs.uuid }}
build-runner-uid: ${{ steps.variables.outputs.runner-uid }}
build-runner-user: ${{ steps.variables.outputs.runner-user }}
git-branch: ${{ steps.variables.outputs.git-branch }}
git-dasherized-branch: ${{ steps.variables.outputs.git-dasherized-branch }}
git-commit-sha: ${{ steps.variables.outputs.git-commit-sha }}
git-commit-short-sha: ${{ steps.variables.outputs.git-commit-short-sha }}
steps:
- # We'll generate a unique id that we'll use to identify the build run
# on our systems
name: Generate UUID for build
id: uuidgen
run: echo "::set-output name=uuid::$(uuidgen)"
- name: Set additional variables
id: variables
uses: icalia-actions/[email protected]
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
- name: Build Test Image
uses: docker/build-push-action@v2
with:
target: testing
platforms: linux/amd64
builder: ${{ steps.buildx.output.name }}
tags: |
icalialabs/xtendize:testing-${{ steps.variables.outputs.git-dasherized-branch }}
icalialabs/xtendize:testing-latest
build-args: |
APP_PATH=${{ github.workspace }}
DEVELOPER_UID=${{ steps.variables.outputs.runner-uid }}
DEVELOPER_USERNAME=${{ steps.variables.outputs.runner-user }}
cache-from: type=gha
cache-to: type=gha,mode=max
testing:
name: Testing
runs-on: ubuntu-latest
needs: [test_build]
env:
BUILD_RUNNER_UID: ${{ needs.test_build.outputs.build-runner-uid }}
BUILD_RUNNER_USER: ${{ needs.test_build.outputs.build-runner-user }}
GIT_DASHERIZED_BRANCH: ${{ needs.test_build.outputs.git-dasherized-branch }}
steps:
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
- name: Load Testing Image
id: load_test_image
uses: docker/build-push-action@v2
with:
builder: ${{ steps.buildx.outputs.name }}
target: testing
# Make the build result to be available in the Docker client:
load: true
platforms: linux/amd64
tags: |
icalialabs/xtendize:testing-${{ env.GIT_DASHERIZED_BRANCH }}
icalialabs/xtendize:testing-latest
build-args: |
APP_PATH=${{ github.workspace }}
DEVELOPER_UID=${{ env.BUILD_RUNNER_UID }}
DEVELOPER_USERNAME=${{ env.BUILD_RUNNER_USER }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Checkout Code
uses: actions/checkout@v1
- name: Run Tests
uses: icalia-actions/[email protected]
with:
service-name: tests
release_build:
name: Build Release
runs-on: ubuntu-latest
needs: [test_build]
env:
BUILD_RUNNER_UID: ${{ needs.test_build.outputs.build-runner-uid }}
BUILD_RUNNER_USER: ${{ needs.test_build.outputs.build-runner-user }}
GIT_DASHERIZED_BRANCH: ${{ needs.test_build.outputs.git-dasherized-branch }}
outputs:
build-runner-uid: ${{ needs.test_build.outputs.build-runner-uid }}
build-runner-user: ${{ needs.test_build.outputs.build-runner-user }}
git-dasherized-branch: ${{ needs.test_build.outputs.git-dasherized-branch }}
steps:
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
- name: Build Releaseable Image
id: build_releaseable_image
uses: docker/build-push-action@v2
with:
target: release
builder: ${{ steps.buildx.outputs.name }}
platforms: linux/amd64
tags: |
icalialabs/xtendize:${{ env.GIT_DASHERIZED_BRANCH }}
icalialabs/xtendize:latest
build-args: |
APP_PATH=${{ github.workspace }}
DEVELOPER_UID=${{ env.BUILD_RUNNER_UID }}
DEVELOPER_USERNAME=${{ env.BUILD_RUNNER_USER }}
cache-from: type=gha
cache-to: type=gha,mode=max
publish_package:
name: Publish Package
runs-on: ubuntu-latest
needs: [testing, release_build]
if: github.event_name == 'release'
env:
BUILD_RUNNER_UID: ${{ needs.release_build.outputs.build-runner-uid }}
BUILD_RUNNER_USER: ${{ needs.release_build.outputs.build-runner-user }}
GIT_DASHERIZED_BRANCH: ${{ needs.release_build.outputs.git-dasherized-branch }}
steps:
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
- name: Load Releaseable Image
id: load_releaseable_image
uses: docker/build-push-action@v2
with:
target: release
builder: ${{ steps.buildx.outputs.name }}
platforms: linux/amd64
load: true
tags: |
icalialabs/xtendize:${{ github.sha }}
icalialabs/xtendize:latest
build-args: |
APP_PATH=${{ github.workspace }}
DEVELOPER_UID=${{ env.BUILD_RUNNER_UID }}
DEVELOPER_USERNAME=${{ env.BUILD_RUNNER_USER }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Publish Package
run: |-
docker run \
-e NPM_AUTH_TOKEN=${{ secrets.ICALIALABS_NPM_TOKEN }} \
icalialabs/xtendize:${{ github.sha }} \
sh -c "find . && yarn publish --non-interactive --access public"