Skip to content

Commit 44e27c2

Browse files
authored
Merge pull request #10 from cytopia/release-0.3
Release 0.3
2 parents a2ad411 + ac540c2 commit 44e27c2

File tree

7 files changed

+540
-174
lines changed

7 files changed

+540
-174
lines changed

.github/workflows/build.yml

Lines changed: 200 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,200 @@
1+
---
2+
3+
# -------------------------------------------------------------------------------------------------
4+
# Job Name
5+
# -------------------------------------------------------------------------------------------------
6+
name: build
7+
8+
9+
# -------------------------------------------------------------------------------------------------
10+
# When to run
11+
# -------------------------------------------------------------------------------------------------
12+
on:
13+
# Runs on Pull Requests
14+
pull_request:
15+
# Runs on Push
16+
push:
17+
18+
19+
# -------------------------------------------------------------------------------------------------
20+
# What to run
21+
# -------------------------------------------------------------------------------------------------
22+
jobs:
23+
build:
24+
name: "[ ${{ matrix.version }} ]"
25+
runs-on: ubuntu-latest
26+
strategy:
27+
fail-fast: False
28+
matrix:
29+
version:
30+
- 'PCF-latest PHP-latest'
31+
- 'PCF-latest PHP-8.0'
32+
- 'PCF-latest PHP-7.4'
33+
- 'PCF-latest PHP-7.3'
34+
- 'PCF-latest PHP-7.2'
35+
- 'PCF-latest PHP-7.1'
36+
- 'PCF-latest PHP-7.0'
37+
- 'PCF-latest PHP-5.6'
38+
39+
- 'PCF-2 PHP-latest'
40+
- 'PCF-2 PHP-8.0'
41+
- 'PCF-2 PHP-7.4'
42+
- 'PCF-2 PHP-7.3'
43+
- 'PCF-2 PHP-7.2'
44+
- 'PCF-2 PHP-7.1'
45+
- 'PCF-2 PHP-7.0'
46+
- 'PCF-2 PHP-5.6'
47+
48+
- 'PCF-1 PHP-latest'
49+
- 'PCF-1 PHP-7.1'
50+
- 'PCF-1 PHP-7.0'
51+
- 'PCF-1 PHP-5.6'
52+
steps:
53+
54+
# ------------------------------------------------------------
55+
# Checkout repository
56+
# ------------------------------------------------------------
57+
- name: Checkout repository
58+
uses: actions/checkout@v2
59+
with:
60+
fetch-depth: 0
61+
62+
- name: Set variables
63+
id: vars
64+
run: |
65+
66+
PCF_VERSION="$( echo "${VERSION}" | awk '{print $1}' | sed 's/PCF\-//g' )"
67+
PHP_VERSION="$( echo "${VERSION}" | awk '{print $2}' | sed 's/PHP\-//g' )"
68+
69+
if [ "${PCF_VERSION}" = "latest" ] && [ "${PHP_VERSION}" = "latest" ]; then
70+
TAG=latest
71+
elif [ "${PHP_VERSION}" = "latest" ]; then
72+
TAG="${PCF_VERSION}"
73+
else
74+
TAG="${PCF_VERSION}-php${PHP_VERSION}"
75+
fi
76+
77+
# Retrieve git info (tags, etc)
78+
git fetch --all
79+
80+
# Branch, Tag or Commit
81+
GIT_TYPE="$( \
82+
curl -sS https://raw.githubusercontent.com/cytopia/git-tools/master/git-info.sh \
83+
| sh \
84+
| grep '^GIT_TYPE' \
85+
| sed 's|.*=||g' \
86+
)"
87+
# Branch name, Tag name or Commit Hash
88+
GIT_SLUG="$( \
89+
curl -sS https://raw.githubusercontent.com/cytopia/git-tools/master/git-info.sh \
90+
| sh \
91+
| grep '^GIT_NAME' \
92+
| sed 's|.*=||g' \
93+
)"
94+
# Docker Tag
95+
if [ "${GIT_TYPE}" = "BRANCH" ] && [ "${GIT_SLUG}" = "master" ]; then
96+
DOCKER_TAG="${TAG}"
97+
else
98+
DOCKER_TAG="${TAG}-${GIT_SLUG}"
99+
fi
100+
101+
# Output
102+
echo "GIT_TYPE=${GIT_TYPE}"
103+
echo "GIT_SLUG=${GIT_SLUG}"
104+
echo "DOCKER_TAG=${DOCKER_TAG}"
105+
echo "PCF_VERSION=${PCF_VERSION}"
106+
echo "PHP_VERSION=${PHP_VERSION}"
107+
108+
# Export variable
109+
# https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-commands-for-github-actions#environment-files
110+
echo "GIT_TYPE=${GIT_TYPE}" >> ${GITHUB_ENV}
111+
echo "GIT_SLUG=${GIT_SLUG}" >> ${GITHUB_ENV}
112+
echo "DOCKER_TAG=${DOCKER_TAG}" >> ${GITHUB_ENV}
113+
echo "PCF_VERSION=${PCF_VERSION}" >> ${GITHUB_ENV}
114+
echo "PHP_VERSION=${PHP_VERSION}" >> ${GITHUB_ENV}
115+
env:
116+
VERSION: ${{ matrix.version }}
117+
118+
119+
# ------------------------------------------------------------
120+
# Build
121+
# ------------------------------------------------------------
122+
- name: Build
123+
run: |
124+
retry() {
125+
for n in $(seq ${RETRIES}); do
126+
echo "[${n}/${RETRIES}] ${*}";
127+
if eval "${*}"; then
128+
echo "[SUCC] ${n}/${RETRIES}";
129+
return 0;
130+
fi;
131+
sleep 2;
132+
echo "[FAIL] ${n}/${RETRIES}";
133+
done;
134+
return 1;
135+
}
136+
retry make build PHP=${PHP_VERSION} PCF=${PCF_VERSION}
137+
env:
138+
RETRIES: 20
139+
140+
- name: Test
141+
run: |
142+
retry() {
143+
for n in $(seq ${RETRIES}); do
144+
echo "[${n}/${RETRIES}] ${*}";
145+
if eval "${*}"; then
146+
echo "[SUCC] ${n}/${RETRIES}";
147+
return 0;
148+
fi;
149+
sleep 2;
150+
echo "[FAIL] ${n}/${RETRIES}";
151+
done;
152+
return 1;
153+
}
154+
retry make test PHP=${PHP_VERSION} PCF=${PCF_VERSION}
155+
env:
156+
RETRIES: 20
157+
158+
159+
# ------------------------------------------------------------
160+
# Deploy
161+
# ------------------------------------------------------------
162+
- name: Publish images (only repo owner)
163+
run: |
164+
retry() {
165+
for n in $(seq ${RETRIES}); do
166+
echo "[${n}/${RETRIES}] ${*}";
167+
if eval "${*}"; then
168+
echo "[SUCC] ${n}/${RETRIES}";
169+
return 0;
170+
fi;
171+
sleep ${PAUSE};
172+
echo "[FAIL] ${n}/${RETRIES}";
173+
done;
174+
return 1;
175+
}
176+
177+
# Output
178+
echo "GIT_TYPE=${GIT_TYPE}"
179+
echo "GIT_SLUG=${GIT_SLUG}"
180+
echo "DOCKER_TAG=${DOCKER_TAG}"
181+
182+
# Tag image
183+
retry make tag TAG=${DOCKER_TAG}
184+
docker images
185+
186+
# Login and Push
187+
retry make login USER=${{ secrets.DOCKERHUB_USERNAME }} PASS=${{ secrets.DOCKERHUB_PASSWORD }}
188+
retry make push TAG=${DOCKER_TAG}
189+
env:
190+
RETRIES: 20
191+
PAUSE: 10
192+
# https://help.github.com/en/github/automating-your-workflow-with-github-actions/contexts-and-expression-syntax-for-github-actions#functions
193+
if: github.event.pull_request.base.repo.id == github.event.pull_request.head.repo.id
194+
&& (
195+
(github.event_name == 'schedule' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/')))
196+
||
197+
(github.event_name == 'push' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/')))
198+
||
199+
(github.event_name == 'push' && startsWith(github.ref, 'refs/heads/release-'))
200+
)

.github/workflows/lint.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
3+
# -------------------------------------------------------------------------------------------------
4+
# Job Name
5+
# -------------------------------------------------------------------------------------------------
6+
name: lint
7+
8+
9+
# -------------------------------------------------------------------------------------------------
10+
# When to run
11+
# -------------------------------------------------------------------------------------------------
12+
on:
13+
# Runs on Pull Requests
14+
pull_request:
15+
16+
17+
# -------------------------------------------------------------------------------------------------
18+
# What to run
19+
# -------------------------------------------------------------------------------------------------
20+
jobs:
21+
lint:
22+
name: "Lint"
23+
runs-on: ubuntu-latest
24+
steps:
25+
# ------------------------------------------------------------
26+
# Setup repository
27+
# ------------------------------------------------------------
28+
- name: Checkout repository
29+
uses: actions/checkout@v2
30+
with:
31+
fetch-depth: 0
32+
33+
# ------------------------------------------------------------
34+
# Lint repository
35+
# ------------------------------------------------------------
36+
- name: Lint
37+
run: |
38+
make lint

0 commit comments

Comments
 (0)