Skip to content

Commit

Permalink
Merge pull request #10 from cytopia/release-0.3
Browse files Browse the repository at this point in the history
Release 0.3
  • Loading branch information
cytopia authored Mar 22, 2021
2 parents a2ad411 + ac540c2 commit 44e27c2
Show file tree
Hide file tree
Showing 7 changed files with 540 additions and 174 deletions.
200 changes: 200 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
---

# -------------------------------------------------------------------------------------------------
# Job Name
# -------------------------------------------------------------------------------------------------
name: build


# -------------------------------------------------------------------------------------------------
# When to run
# -------------------------------------------------------------------------------------------------
on:
# Runs on Pull Requests
pull_request:
# Runs on Push
push:


# -------------------------------------------------------------------------------------------------
# What to run
# -------------------------------------------------------------------------------------------------
jobs:
build:
name: "[ ${{ matrix.version }} ]"
runs-on: ubuntu-latest
strategy:
fail-fast: False
matrix:
version:
- 'PCF-latest PHP-latest'
- 'PCF-latest PHP-8.0'
- 'PCF-latest PHP-7.4'
- 'PCF-latest PHP-7.3'
- 'PCF-latest PHP-7.2'
- 'PCF-latest PHP-7.1'
- 'PCF-latest PHP-7.0'
- 'PCF-latest PHP-5.6'

- 'PCF-2 PHP-latest'
- 'PCF-2 PHP-8.0'
- 'PCF-2 PHP-7.4'
- 'PCF-2 PHP-7.3'
- 'PCF-2 PHP-7.2'
- 'PCF-2 PHP-7.1'
- 'PCF-2 PHP-7.0'
- 'PCF-2 PHP-5.6'

- 'PCF-1 PHP-latest'
- 'PCF-1 PHP-7.1'
- 'PCF-1 PHP-7.0'
- 'PCF-1 PHP-5.6'
steps:

# ------------------------------------------------------------
# Checkout repository
# ------------------------------------------------------------
- name: Checkout repository
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Set variables
id: vars
run: |
PCF_VERSION="$( echo "${VERSION}" | awk '{print $1}' | sed 's/PCF\-//g' )"
PHP_VERSION="$( echo "${VERSION}" | awk '{print $2}' | sed 's/PHP\-//g' )"
if [ "${PCF_VERSION}" = "latest" ] && [ "${PHP_VERSION}" = "latest" ]; then
TAG=latest
elif [ "${PHP_VERSION}" = "latest" ]; then
TAG="${PCF_VERSION}"
else
TAG="${PCF_VERSION}-php${PHP_VERSION}"
fi
# Retrieve git info (tags, etc)
git fetch --all
# Branch, Tag or Commit
GIT_TYPE="$( \
curl -sS https://raw.githubusercontent.com/cytopia/git-tools/master/git-info.sh \
| sh \
| grep '^GIT_TYPE' \
| sed 's|.*=||g' \
)"
# Branch name, Tag name or Commit Hash
GIT_SLUG="$( \
curl -sS https://raw.githubusercontent.com/cytopia/git-tools/master/git-info.sh \
| sh \
| grep '^GIT_NAME' \
| sed 's|.*=||g' \
)"
# Docker Tag
if [ "${GIT_TYPE}" = "BRANCH" ] && [ "${GIT_SLUG}" = "master" ]; then
DOCKER_TAG="${TAG}"
else
DOCKER_TAG="${TAG}-${GIT_SLUG}"
fi
# Output
echo "GIT_TYPE=${GIT_TYPE}"
echo "GIT_SLUG=${GIT_SLUG}"
echo "DOCKER_TAG=${DOCKER_TAG}"
echo "PCF_VERSION=${PCF_VERSION}"
echo "PHP_VERSION=${PHP_VERSION}"
# Export variable
# https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-commands-for-github-actions#environment-files
echo "GIT_TYPE=${GIT_TYPE}" >> ${GITHUB_ENV}
echo "GIT_SLUG=${GIT_SLUG}" >> ${GITHUB_ENV}
echo "DOCKER_TAG=${DOCKER_TAG}" >> ${GITHUB_ENV}
echo "PCF_VERSION=${PCF_VERSION}" >> ${GITHUB_ENV}
echo "PHP_VERSION=${PHP_VERSION}" >> ${GITHUB_ENV}
env:
VERSION: ${{ matrix.version }}


# ------------------------------------------------------------
# Build
# ------------------------------------------------------------
- name: Build
run: |
retry() {
for n in $(seq ${RETRIES}); do
echo "[${n}/${RETRIES}] ${*}";
if eval "${*}"; then
echo "[SUCC] ${n}/${RETRIES}";
return 0;
fi;
sleep 2;
echo "[FAIL] ${n}/${RETRIES}";
done;
return 1;
}
retry make build PHP=${PHP_VERSION} PCF=${PCF_VERSION}
env:
RETRIES: 20

- name: Test
run: |
retry() {
for n in $(seq ${RETRIES}); do
echo "[${n}/${RETRIES}] ${*}";
if eval "${*}"; then
echo "[SUCC] ${n}/${RETRIES}";
return 0;
fi;
sleep 2;
echo "[FAIL] ${n}/${RETRIES}";
done;
return 1;
}
retry make test PHP=${PHP_VERSION} PCF=${PCF_VERSION}
env:
RETRIES: 20


# ------------------------------------------------------------
# Deploy
# ------------------------------------------------------------
- name: Publish images (only repo owner)
run: |
retry() {
for n in $(seq ${RETRIES}); do
echo "[${n}/${RETRIES}] ${*}";
if eval "${*}"; then
echo "[SUCC] ${n}/${RETRIES}";
return 0;
fi;
sleep ${PAUSE};
echo "[FAIL] ${n}/${RETRIES}";
done;
return 1;
}
# Output
echo "GIT_TYPE=${GIT_TYPE}"
echo "GIT_SLUG=${GIT_SLUG}"
echo "DOCKER_TAG=${DOCKER_TAG}"
# Tag image
retry make tag TAG=${DOCKER_TAG}
docker images
# Login and Push
retry make login USER=${{ secrets.DOCKERHUB_USERNAME }} PASS=${{ secrets.DOCKERHUB_PASSWORD }}
retry make push TAG=${DOCKER_TAG}
env:
RETRIES: 20
PAUSE: 10
# https://help.github.com/en/github/automating-your-workflow-with-github-actions/contexts-and-expression-syntax-for-github-actions#functions
if: github.event.pull_request.base.repo.id == github.event.pull_request.head.repo.id
&& (
(github.event_name == 'schedule' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/')))
||
(github.event_name == 'push' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/')))
||
(github.event_name == 'push' && startsWith(github.ref, 'refs/heads/release-'))
)
38 changes: 38 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---

# -------------------------------------------------------------------------------------------------
# Job Name
# -------------------------------------------------------------------------------------------------
name: lint


# -------------------------------------------------------------------------------------------------
# When to run
# -------------------------------------------------------------------------------------------------
on:
# Runs on Pull Requests
pull_request:


# -------------------------------------------------------------------------------------------------
# What to run
# -------------------------------------------------------------------------------------------------
jobs:
lint:
name: "Lint"
runs-on: ubuntu-latest
steps:
# ------------------------------------------------------------
# Setup repository
# ------------------------------------------------------------
- name: Checkout repository
uses: actions/checkout@v2
with:
fetch-depth: 0

# ------------------------------------------------------------
# Lint repository
# ------------------------------------------------------------
- name: Lint
run: |
make lint
Loading

0 comments on commit 44e27c2

Please sign in to comment.