@@ -10,148 +10,151 @@ name: build
10
10
# When to run
11
11
# -------------------------------------------------------------------------------------------------
12
12
on :
13
- # Runs on Pull Requests
14
- pull_request :
15
13
# Runs on Push
16
14
push :
17
15
18
16
19
- # -------------------------------------------------------------------------------------------------
20
- # What to run
21
- # -------------------------------------------------------------------------------------------------
22
17
jobs :
18
+
19
+ # -----------------------------------------------------------------------------------------------
20
+ # Job (1/2): BUILD
21
+ # -----------------------------------------------------------------------------------------------
23
22
build :
24
- name : " [ HTTPD ]"
23
+ name : " [ ${{ matrix.version }} (${{ matrix.arch }}) ]"
25
24
runs-on : ubuntu-latest
25
+ strategy :
26
+ fail-fast : false
27
+ matrix :
28
+ version :
29
+ - ' Nginx stable'
30
+ arch :
31
+ - ' linux/amd64'
32
+ - ' linux/arm64'
33
+ - ' linux/386'
34
+ - ' linux/arm/v7'
35
+ - ' linux/arm/v6'
26
36
steps :
27
37
28
38
# ------------------------------------------------------------
29
39
# Setup repository
30
40
# ------------------------------------------------------------
31
- - name : Checkout repository
41
+ - name : " [SETUP] Checkout repository"
32
42
uses : actions/checkout@v2
33
43
with :
34
44
fetch-depth : 0
35
45
36
- - name : Set variables
37
- id : vars
38
- run : |
39
-
40
- # Retrieve git info (tags, etc)
41
- git fetch --all
42
-
43
- # Branch, Tag or Commit
44
- GIT_TYPE="$( \
45
- curl -sS https://raw.githubusercontent.com/cytopia/git-tools/master/git-info.sh \
46
- | sh \
47
- | grep '^GIT_TYPE' \
48
- | sed 's|.*=||g' \
49
- )"
50
- # Branch name, Tag name or Commit Hash
51
- GIT_SLUG="$( \
52
- curl -sS https://raw.githubusercontent.com/cytopia/git-tools/master/git-info.sh \
53
- | sh \
54
- | grep '^GIT_NAME' \
55
- | sed 's|.*=||g' \
56
- )"
57
- # Docker Tag
58
- if [ "${GIT_TYPE}" = "BRANCH" ] && [ "${GIT_SLUG}" = "master" ]; then
59
- DOCKER_TAG="latest"
60
- else
61
- DOCKER_TAG="${GIT_SLUG}"
62
- fi
63
-
64
- # Output
65
- echo "GIT_TYPE=${GIT_TYPE}"
66
- echo "GIT_SLUG=${GIT_SLUG}"
67
- echo "DOCKER_TAG=${DOCKER_TAG}"
68
-
69
- # Export variable
70
- # https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-commands-for-github-actions#environment-files
71
- echo "GIT_TYPE=${GIT_TYPE}" >> ${GITHUB_ENV}
72
- echo "GIT_SLUG=${GIT_SLUG}" >> ${GITHUB_ENV}
73
- echo "DOCKER_TAG=${DOCKER_TAG}" >> ${GITHUB_ENV}
46
+ - name : " [SETUP] Setup QEMU environment"
47
+ uses : docker/setup-qemu-action@v1
48
+ with :
49
+ image : tonistiigi/binfmt:latest
50
+ platforms : all
74
51
52
+ - name : " [SETUP] Determine Docker tag"
53
+ id : tag
54
+
75
55
76
56
# ------------------------------------------------------------
77
57
# Build
78
58
# ------------------------------------------------------------
79
59
- name : Build
80
- run : |
81
- retry() {
82
- for n in $(seq ${RETRIES}); do
83
- echo "[${n}/${RETRIES}] ${*}";
84
- if eval "${*}"; then
85
- echo "[SUCC] ${n}/${RETRIES}";
86
- return 0;
87
- fi;
88
- sleep ${PAUSE};
89
- echo "[FAIL] ${n}/${RETRIES}";
90
- done;
91
- return 1;
92
- }
93
- retry make build
60
+
61
+ with :
62
+ command : |
63
+ make build ARCH=${ARCH}
94
64
env :
95
- RETRIES : 20
96
- PAUSE : 10
65
+ ARCH : ${{ matrix.arch }}
97
66
98
67
# ------------------------------------------------------------
99
68
# Test
100
69
# ------------------------------------------------------------
101
- - name : Test Docker Image
102
- run : |
103
- retry() {
104
- for n in $(seq ${RETRIES}); do
105
- echo "[${n}/${RETRIES}] ${*}";
106
- if eval "${*}"; then
107
- echo "[SUCC] ${n}/${RETRIES}";
108
- return 0;
109
- fi;
110
- sleep ${PAUSE};
111
- echo "[FAIL] ${n}/${RETRIES}";
112
- done;
113
- return 1;
114
- }
115
- retry make test
70
+ - name : " [TEST] Docker Image"
71
+
72
+ with :
73
+ command : |
74
+ make test ARCH=${ARCH}
116
75
env :
117
- RETRIES : 20
118
- PAUSE : 10
76
+ ARCH : ${{ matrix.arch }}
119
77
78
+ - name : " [TEST] Update README"
79
+
80
+ with :
81
+ command : |
82
+ make update-readme ARCH=${ARCH}
83
+ env :
84
+ ARCH : ${{ matrix.arch }}
120
85
121
86
# ------------------------------------------------------------
122
87
# Deploy
123
88
# ------------------------------------------------------------
124
- - name : Publish images (only repo owner)
125
- run : |
126
- retry() {
127
- for n in $(seq ${RETRIES}); do
128
- echo "[${n}/${RETRIES}] ${*}";
129
- if eval "${*}"; then
130
- echo "[SUCC] ${n}/${RETRIES}";
131
- return 0;
132
- fi;
133
- sleep ${PAUSE};
134
- echo "[FAIL] ${n}/${RETRIES}";
135
- done;
136
- return 1;
137
- }
138
-
139
- # Output
140
- echo "GIT_TYPE=${GIT_TYPE}"
141
- echo "GIT_SLUG=${GIT_SLUG}"
142
- echo "DOCKER_TAG=${DOCKER_TAG}"
143
-
144
- # Tag image
145
- retry make tag TAG=${DOCKER_TAG}
146
- docker images
147
-
148
- # Login and Push
149
- retry make login USER=${{ secrets.DOCKERHUB_USERNAME }} PASS=${{ secrets.DOCKERHUB_PASSWORD }}
150
- retry make push TAG=${DOCKER_TAG}
89
+ - name : " [DEPLOY] Login"
90
+ uses : docker/login-action@v1
91
+ with :
92
+ username : ${{ secrets.DOCKERHUB_USERNAME }}
93
+ password : ${{ secrets.DOCKERHUB_PASSWORD }}
151
94
95
+ - name : " [DEPLOY] Publish architecture image (only repo owner)"
96
+
97
+ with :
98
+ command : |
99
+ make push-arch TAG=${{ steps.tag.outputs.docker-tag }} ARCH=${ARCH}
152
100
env :
153
- RETRIES : 20
154
- PAUSE : 10
101
+ ARCH : ${{ matrix.arch }}
102
+ # https://help.github.com/en/github/automating-your-workflow-with-github-actions/contexts-and-expression-syntax-for-github-actions#functions
103
+ if : github.event.pull_request.base.repo.id == github.event.pull_request.head.repo.id
104
+ && (
105
+ (github.event_name == 'schedule' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/')))
106
+ ||
107
+ (github.event_name == 'push' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/')))
108
+ ||
109
+ (github.event_name == 'push' && startsWith(github.ref, 'refs/heads/release-'))
110
+ )
111
+
112
+ # -----------------------------------------------------------------------------------------------
113
+ # Job (2/2): DEPLOY
114
+ # -----------------------------------------------------------------------------------------------
115
+ deploy :
116
+ needs : [build]
117
+ name : Deploy
118
+ runs-on : ubuntu-latest
119
+ strategy :
120
+ fail-fast : false
121
+ matrix :
122
+ version :
123
+ - ' Nginx stable'
124
+ steps :
125
+
126
+ # ------------------------------------------------------------
127
+ # Setup repository
128
+ # ------------------------------------------------------------
129
+ - name : " [SETUP] Checkout repository"
130
+ uses : actions/checkout@v2
131
+ with :
132
+ fetch-depth : 0
133
+
134
+ - name : " [SETUP] Determine Docker tag"
135
+ id : tag
136
+
137
+
138
+ # ------------------------------------------------------------
139
+ # Deploy
140
+ # ------------------------------------------------------------
141
+ - name : " [DEPLOY] Login"
142
+ uses : docker/login-action@v1
143
+ with :
144
+ username : ${{ secrets.DOCKERHUB_USERNAME }}
145
+ password : ${{ secrets.DOCKERHUB_PASSWORD }}
146
+
147
+ - name : " [DEPLOY] Create Docker manifest"
148
+
149
+ with :
150
+ command : |
151
+ make manifest-create TAG=${{ steps.tag.outputs.docker-tag }} ARCH="linux/amd64,linux/arm64,linux/386,linux/arm/v7,linux/arm/v6"
152
+
153
+ - name : " [DEPLOY] Publish Docker manifest (only repo owner)"
154
+
155
+ with :
156
+ command : |
157
+ make manifest-push TAG=${{ steps.tag.outputs.docker-tag }}
155
158
# https://help.github.com/en/github/automating-your-workflow-with-github-actions/contexts-and-expression-syntax-for-github-actions#functions
156
159
if : github.event.pull_request.base.repo.id == github.event.pull_request.head.repo.id
157
160
&& (
0 commit comments