@@ -10,173 +10,155 @@ name: build
1010# When to run
1111# -------------------------------------------------------------------------------------------------
1212on :
13- # Runs on Pull Requests
14- pull_request :
1513 # Runs on Push
1614 push :
1715
1816
19- # -------------------------------------------------------------------------------------------------
20- # What to run
21- # -------------------------------------------------------------------------------------------------
2217jobs :
18+
19+ # -----------------------------------------------------------------------------------------------
20+ # Job (1/2): BUILD
21+ # -----------------------------------------------------------------------------------------------
2322 build :
24- name : " [ PHP-${{ matrix.version }} ]"
23+ name : " [ PHP-${{ matrix.version }} (${{ matrix.arch }}) ]"
2524 runs-on : ubuntu-latest
2625 strategy :
27- fail-fast : False
26+ fail-fast : false
2827 matrix :
2928 version :
3029 - ' 5.3'
30+ arch :
31+ - ' linux/amd64'
32+ - ' linux/arm64'
33+ - ' linux/386'
34+ - ' linux/arm/v7'
35+ - ' linux/arm/v6'
3136 steps :
3237
3338 # ------------------------------------------------------------
3439 # Setup repository
3540 # ------------------------------------------------------------
36- - name : Checkout repository
41+ - name : " [SETUP] Checkout repository"
3742 uses : actions/checkout@v2
3843 with :
3944 fetch-depth : 0
4045
41- - name : Set variables
42- id : vars
43- run : |
44-
45- # Retrieve git info (tags, etc)
46- git fetch --all
47-
48- # Branch, Tag or Commit
49- GIT_TYPE="$( \
50- curl -sS https://raw.githubusercontent.com/cytopia/git-tools/master/git-info.sh \
51- | sh \
52- | grep '^GIT_TYPE' \
53- | sed 's|.*=||g' \
54- )"
55- # Branch name, Tag name or Commit Hash
56- GIT_SLUG="$( \
57- curl -sS https://raw.githubusercontent.com/cytopia/git-tools/master/git-info.sh \
58- | sh \
59- | grep '^GIT_NAME' \
60- | sed 's|.*=||g' \
61- )"
62- # Docker Tag
63- if [ "${GIT_TYPE}" = "BRANCH" ] && [ "${GIT_SLUG}" = "master" ]; then
64- DOCKER_TAG="latest"
65- else
66- DOCKER_TAG="${GIT_SLUG}"
67- fi
68-
69- # Output
70- echo "GIT_TYPE=${GIT_TYPE}"
71- echo "GIT_SLUG=${GIT_SLUG}"
72- echo "DOCKER_TAG=${DOCKER_TAG}"
73-
74- # Export variable
75- # https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-commands-for-github-actions#environment-files
76- echo "GIT_TYPE=${GIT_TYPE}" >> ${GITHUB_ENV}
77- echo "GIT_SLUG=${GIT_SLUG}" >> ${GITHUB_ENV}
78- 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
7951
52+ - name : " [SETUP] Determine Docker tag"
53+ id : tag
54+ uses : cytopia/docker-tag@v0.3
8055
8156 # ------------------------------------------------------------
8257 # Build
8358 # ------------------------------------------------------------
8459 - name : Build
85- run : |
86- retry() {
87- for n in $(seq ${RETRIES}); do
88- echo "[${n}/${RETRIES}] ${*}";
89- if eval "${*}"; then
90- echo "[SUCC] ${n}/${RETRIES}";
91- return 0;
92- fi;
93- sleep ${PAUSE};
94- echo "[FAIL] ${n}/${RETRIES}";
95- done;
96- return 1;
97- }
98- retry make build
60+ uses : cytopia/shell-command-retry-action@v0.1
61+ with :
62+ command : |
63+ make build ARCH=${ARCH}
9964 env :
100- RETRIES : 20
101- PAUSE : 10
65+ ARCH : ${{ matrix.arch }}
10266
10367 # ------------------------------------------------------------
10468 # Test
10569 # ------------------------------------------------------------
106- - name : Test Docker Image
107- run : |
108- retry() {
109- for n in $(seq ${RETRIES}); do
110- echo "[${n}/${RETRIES}] ${*}";
111- if eval "${*}"; then
112- echo "[SUCC] ${n}/${RETRIES}";
113- return 0;
114- fi;
115- sleep ${PAUSE};
116- echo "[FAIL] ${n}/${RETRIES}";
117- done;
118- return 1;
119- }
120- retry make test
70+ - name : " [TEST] Docker Image"
71+ uses : cytopia/shell-command-retry-action@v0.1
72+ with :
73+ command : |
74+ make test ARCH=${ARCH}
75+ env :
76+ ARCH : ${{ matrix.arch }}
77+
78+ - name : " [TEST] Update README"
79+ uses : cytopia/shell-command-retry-action@v0.1
80+ with :
81+ command : |
82+ make update-readme ARCH=${ARCH}
12183 env :
122- RETRIES : 20
123- PAUSE : 10
84+ ARCH : ${{ matrix.arch }}
12485
125- - name : Test Repository Readme
86+ - name : " [TEST] Verify README "
12687 run : |
127- retry() {
128- for n in $(seq ${RETRIES}); do
129- echo "[${n}/${RETRIES}] ${*}";
130- if eval "${*}"; then
131- echo "[SUCC] ${n}/${RETRIES}";
132- return 0;
133- fi;
134- sleep ${PAUSE};
135- echo "[FAIL] ${n}/${RETRIES}";
136- done;
137- return 1;
138- }
139- retry make update-readme
14088 git diff --quiet || { echo "Build Changes"; git diff; git status; false; }
89+
90+ # ------------------------------------------------------------
91+ # Deploy
92+ # ------------------------------------------------------------
93+ - name : " [DEPLOY] Login"
94+ uses : docker/login-action@v1
95+ with :
96+ username : ${{ secrets.DOCKERHUB_USERNAME }}
97+ password : ${{ secrets.DOCKERHUB_PASSWORD }}
98+
99+ - name : " [DEPLOY] Publish architecture image (only repo owner)"
100+ uses : cytopia/shell-command-retry-action@v0.1
101+ with :
102+ command : |
103+ make push-arch TAG=${{ steps.tag.outputs.docker-tag }} ARCH=${ARCH}
141104 env :
142- RETRIES : 20
143- PAUSE : 10
105+ ARCH : ${{ matrix.arch }}
106+ # https://help.github.com/en/github/automating-your-workflow-with-github-actions/contexts-and-expression-syntax-for-github-actions#functions
107+ if : github.event.pull_request.base.repo.id == github.event.pull_request.head.repo.id
108+ && (
109+ (github.event_name == 'schedule' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/')))
110+ ||
111+ (github.event_name == 'push' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/')))
112+ ||
113+ (github.event_name == 'push' && startsWith(github.ref, 'refs/heads/release-'))
114+ )
115+
116+ # -----------------------------------------------------------------------------------------------
117+ # Job (2/2): DEPLOY
118+ # -----------------------------------------------------------------------------------------------
119+ deploy :
120+ needs : [build]
121+ name : Deploy
122+ runs-on : ubuntu-latest
123+ strategy :
124+ fail-fast : false
125+ matrix :
126+ version :
127+ - ' 5.3'
128+ steps :
129+
130+ # ------------------------------------------------------------
131+ # Setup repository
132+ # ------------------------------------------------------------
133+ - name : " [SETUP] Checkout repository"
134+ uses : actions/checkout@v2
135+ with :
136+ fetch-depth : 0
144137
138+ - name : " [SETUP] Determine Docker tag"
139+ id : tag
140+ uses : cytopia/docker-tag@v0.3
145141
146142 # ------------------------------------------------------------
147143 # Deploy
148144 # ------------------------------------------------------------
149- - name : Publish images (only repo owner)
150- run : |
151- retry() {
152- for n in $(seq ${RETRIES}); do
153- echo "[${n}/${RETRIES}] ${*}";
154- if eval "${*}"; then
155- echo "[SUCC] ${n}/${RETRIES}";
156- return 0;
157- fi;
158- sleep ${PAUSE};
159- echo "[FAIL] ${n}/${RETRIES}";
160- done;
161- return 1;
162- }
163-
164- # Output
165- echo "GIT_TYPE=${GIT_TYPE}"
166- echo "GIT_SLUG=${GIT_SLUG}"
167- echo "DOCKER_TAG=${DOCKER_TAG}"
168-
169- # Tag image
170- retry make tag TAG=${DOCKER_TAG}
171- docker images
172-
173- # Login and Push
174- retry make login USER=${{ secrets.DOCKERHUB_USERNAME }} PASS=${{ secrets.DOCKERHUB_PASSWORD }}
175- retry make push TAG=${DOCKER_TAG}
145+ - name : " [DEPLOY] Login"
146+ uses : docker/login-action@v1
147+ with :
148+ username : ${{ secrets.DOCKERHUB_USERNAME }}
149+ password : ${{ secrets.DOCKERHUB_PASSWORD }}
176150
177- env :
178- RETRIES : 20
179- PAUSE : 10
151+ - name : " [DEPLOY] Create Docker manifest"
152+ uses : cytopia/shell-command-retry-action@v0.1
153+ with :
154+ command : |
155+ make manifest-create TAG=${{ steps.tag.outputs.docker-tag }} ARCH="linux/amd64,linux/arm64,linux/386,linux/arm/v7,linux/arm/v6"
156+
157+ - name : " [DEPLOY] Publish Docker manifest (only repo owner)"
158+ uses : cytopia/shell-command-retry-action@v0.1
159+ with :
160+ command : |
161+ make manifest-push TAG=${{ steps.tag.outputs.docker-tag }}
180162 # https://help.github.com/en/github/automating-your-workflow-with-github-actions/contexts-and-expression-syntax-for-github-actions#functions
181163 if : github.event.pull_request.base.repo.id == github.event.pull_request.head.repo.id
182164 && (
0 commit comments