Skip to content

Commit fc72b8c

Browse files
authored
Merge pull request #10 from devilbox/release-0.8
Release 0.8
2 parents b93e411 + 54f2785 commit fc72b8c

9 files changed

Lines changed: 632 additions & 296 deletions

File tree

.github/workflows/build.yml

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
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.images }} ]"
25+
runs-on: ubuntu-latest
26+
strategy:
27+
fail-fast: false
28+
matrix:
29+
images:
30+
- 'mysql 5.5'
31+
- 'mysql 5.6'
32+
- 'mysql 5.7'
33+
- 'mysql 8.0'
34+
- 'mariadb 5.5'
35+
- 'mariadb 10.0'
36+
- 'mariadb 10.1'
37+
- 'mariadb 10.2'
38+
- 'mariadb 10.3'
39+
- 'mariadb 10.4'
40+
- 'mariadb 10.5'
41+
- 'mariadb 10.6'
42+
- 'mariadb 10.7'
43+
- 'percona 5.5'
44+
- 'percona 5.6'
45+
- 'percona 5.7'
46+
- 'percona 8.0'
47+
steps:
48+
# ------------------------------------------------------------
49+
# Setup repository
50+
# ------------------------------------------------------------
51+
- name: Checkout repository
52+
uses: actions/checkout@v2
53+
with:
54+
fetch-depth: 0
55+
56+
- name: Set variables
57+
id: vars
58+
run: |
59+
60+
# Separate version and name
61+
MYSQL="$( echo "${IMAGES}" | awk '{print $1}' )"
62+
VERSION="$( echo "${IMAGES}" | awk '{print $2}' )"
63+
64+
# Retrieve git info (tags, etc)
65+
git fetch --all
66+
67+
# Branch, Tag or Commit
68+
GIT_TYPE="$( \
69+
curl -sS https://raw.githubusercontent.com/cytopia/git-tools/master/git-info.sh \
70+
| sh \
71+
| grep '^GIT_TYPE' \
72+
| sed 's|.*=||g' \
73+
)"
74+
# Branch name, Tag name or Commit Hash
75+
GIT_SLUG="$( \
76+
curl -sS https://raw.githubusercontent.com/cytopia/git-tools/master/git-info.sh \
77+
| sh \
78+
| grep '^GIT_NAME' \
79+
| sed 's|.*=||g' \
80+
)"
81+
# Docker Tag
82+
if [ "${GIT_TYPE}" = "BRANCH" ] && [ "${GIT_SLUG}" = "master" ]; then
83+
DOCKER_TAG="${MYSQL}-${VERSION}"
84+
else
85+
DOCKER_TAG="${MYSQL}-${VERSION}-${GIT_SLUG}"
86+
fi
87+
88+
# Output
89+
echo "GIT_TYPE=${GIT_TYPE}"
90+
echo "GIT_SLUG=${GIT_SLUG}"
91+
echo "DOCKER_TAG=${DOCKER_TAG}"
92+
echo "MYSQL=${MYSQL}"
93+
echo "VERSION=${VERSION}"
94+
95+
# Export variable
96+
# https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-commands-for-github-actions#environment-files
97+
echo "GIT_TYPE=${GIT_TYPE}" >> ${GITHUB_ENV}
98+
echo "GIT_SLUG=${GIT_SLUG}" >> ${GITHUB_ENV}
99+
echo "DOCKER_TAG=${DOCKER_TAG}" >> ${GITHUB_ENV}
100+
echo "MYSQL=${MYSQL}" >> ${GITHUB_ENV}
101+
echo "VERSION=${VERSION}" >> ${GITHUB_ENV}
102+
env:
103+
IMAGES: ${{ matrix.images }}
104+
105+
106+
# ------------------------------------------------------------
107+
# Builder
108+
# ------------------------------------------------------------
109+
- name: Build
110+
run: |
111+
retry() {
112+
for n in $(seq ${RETRIES}); do
113+
echo "[${n}/${RETRIES}] ${*}";
114+
if eval "${*}"; then
115+
echo "[SUCC] ${n}/${RETRIES}";
116+
return 0;
117+
fi;
118+
sleep 2;
119+
echo "[FAIL] ${n}/${RETRIES}";
120+
done;
121+
return 1;
122+
}
123+
retry make build MYSQL=${MYSQL} VERSION=${VERSION}
124+
env:
125+
RETRIES: 10
126+
127+
# ------------------------------------------------------------
128+
# Test
129+
# ------------------------------------------------------------
130+
- name: Test
131+
run: |
132+
retry() {
133+
for n in $(seq ${RETRIES}); do
134+
echo "[${n}/${RETRIES}] ${*}";
135+
if eval "${*}"; then
136+
echo "[SUCC] ${n}/${RETRIES}";
137+
return 0;
138+
fi;
139+
sleep 2;
140+
echo "[FAIL] ${n}/${RETRIES}";
141+
done;
142+
return 1;
143+
}
144+
retry make test MYSQL=${MYSQL} VERSION=${VERSION}
145+
env:
146+
RETRIES: 10
147+
148+
# ------------------------------------------------------------
149+
# Deploy
150+
# ------------------------------------------------------------
151+
- name: Publish images (only repo owner)
152+
run: |
153+
154+
# Output
155+
echo "GIT_TYPE=${GIT_TYPE}"
156+
echo "GIT_SLUG=${GIT_SLUG}"
157+
echo "DOCKER_TAG=${DOCKER}"
158+
echo "MYSQL=${MYSQL}"
159+
echo "VERSION=${VERSION}"
160+
161+
# Tag image
162+
make tag MYSQL=${MYSQL} VERSION=${VERSION} TAG=${DOCKER_TAG}
163+
docker images | grep devilbox
164+
165+
# Login
166+
make login USERNAME=${{ secrets.DOCKERHUB_USERNAME }} PASSWORD=${{ secrets.DOCKERHUB_PASSWORD }}
167+
168+
# Push
169+
make push TAG=${DOCKER_TAG}
170+
# https://help.github.com/en/github/automating-your-workflow-with-github-actions/contexts-and-expression-syntax-for-github-actions#functions
171+
if: github.event.pull_request.base.repo.id == github.event.pull_request.head.repo.id
172+
&& (
173+
(github.event_name == 'schedule' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/')))
174+
||
175+
(github.event_name == 'push' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/')))
176+
||
177+
(github.event_name == 'push' && startsWith(github.ref, 'refs/heads/release-'))
178+
)

.github/workflows/lint.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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 Files
37+
run: |
38+
make lint-files
39+
40+
# ------------------------------------------------------------
41+
# Lint Workflow
42+
# ------------------------------------------------------------
43+
- name: Lint Workflow
44+
run: |
45+
make lint-workflow

.github/workflows/mysql-ci.yml

Lines changed: 0 additions & 100 deletions
This file was deleted.

0 commit comments

Comments
 (0)