Skip to content

Commit

Permalink
Merge pull request #35 from devilbox/release-0.40
Browse files Browse the repository at this point in the history
Release 0.40
  • Loading branch information
cytopia authored Feb 13, 2022
2 parents 2c828bb + b84d059 commit f1649f7
Show file tree
Hide file tree
Showing 13 changed files with 415 additions and 265 deletions.
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 2
updates:
# Maintain dependencies for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
217 changes: 110 additions & 107 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,148 +10,151 @@ name: build
# When to run
# -------------------------------------------------------------------------------------------------
on:
# Runs on Pull Requests
pull_request:
# Runs on Push
push:


# -------------------------------------------------------------------------------------------------
# What to run
# -------------------------------------------------------------------------------------------------
jobs:

# -----------------------------------------------------------------------------------------------
# Job (1/2): BUILD
# -----------------------------------------------------------------------------------------------
build:
name: "[ HTTPD ]"
name: "[ ${{ matrix.version }} (${{ matrix.arch }}) ]"
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
version:
- 'Apache 2.4'
arch:
- 'linux/amd64'
- 'linux/arm64'
- 'linux/386'
- 'linux/arm/v7'
- 'linux/arm/v6'
steps:

# ------------------------------------------------------------
# Setup repository
# ------------------------------------------------------------
- name: Checkout repository
- name: "[SETUP] Checkout repository"
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Set variables
id: vars
run: |
# 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="latest"
else
DOCKER_TAG="${GIT_SLUG}"
fi
# Output
echo "GIT_TYPE=${GIT_TYPE}"
echo "GIT_SLUG=${GIT_SLUG}"
echo "DOCKER_TAG=${DOCKER_TAG}"
# 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}
- name: "[SETUP] Setup QEMU environment"
uses: docker/setup-qemu-action@v1
with:
image: tonistiigi/binfmt:latest
platforms: all

- name: "[SETUP] Determine Docker tag"
id: tag
uses: cytopia/[email protected]

# ------------------------------------------------------------
# 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 ${PAUSE};
echo "[FAIL] ${n}/${RETRIES}";
done;
return 1;
}
retry make build
uses: cytopia/[email protected]
with:
command: |
make build ARCH=${ARCH}
env:
RETRIES: 20
PAUSE: 10
ARCH: ${{ matrix.arch }}

# ------------------------------------------------------------
# Test
# ------------------------------------------------------------
- name: Test Docker Image
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;
}
retry make test
- name: "[TEST] Docker Image"
uses: cytopia/[email protected]
with:
command: |
make test ARCH=${ARCH}
env:
RETRIES: 20
PAUSE: 10
ARCH: ${{ matrix.arch }}

- name: "[TEST] Update README"
uses: cytopia/[email protected]
with:
command: |
make update-readme ARCH=${ARCH}
env:
ARCH: ${{ matrix.arch }}

# ------------------------------------------------------------
# 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}
- name: "[DEPLOY] Login"
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: "[DEPLOY] Publish architecture image (only repo owner)"
uses: cytopia/[email protected]
with:
command: |
make push-arch TAG=${{ steps.tag.outputs.docker-tag }} ARCH=${ARCH}
env:
RETRIES: 20
PAUSE: 10
ARCH: ${{ matrix.arch }}
# 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-'))
)

# -----------------------------------------------------------------------------------------------
# Job (2/2): DEPLOY
# -----------------------------------------------------------------------------------------------
deploy:
needs: [build]
name: Deploy
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
version:
- 'Apache 2.4'
steps:

# ------------------------------------------------------------
# Setup repository
# ------------------------------------------------------------
- name: "[SETUP] Checkout repository"
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: "[SETUP] Determine Docker tag"
id: tag
uses: cytopia/[email protected]

# ------------------------------------------------------------
# Deploy
# ------------------------------------------------------------
- name: "[DEPLOY] Login"
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: "[DEPLOY] Create Docker manifest"
uses: cytopia/[email protected]
with:
command: |
make manifest-create TAG=${{ steps.tag.outputs.docker-tag }} ARCH="linux/amd64,linux/arm64,linux/386,linux/arm/v7,linux/arm/v6"
- name: "[DEPLOY] Publish Docker manifest (only repo owner)"
uses: cytopia/[email protected]
with:
command: |
make manifest-push TAG=${{ steps.tag.outputs.docker-tag }}
# 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
&& (
Expand Down
86 changes: 86 additions & 0 deletions .github/workflows/contributor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
---

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


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


jobs:

# -----------------------------------------------------------------------------------------------
# Job (1/2): BUILD
# -----------------------------------------------------------------------------------------------
build:
name: "[ ${{ matrix.version }} (${{ matrix.arch }}) ]"
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
version:
- 'Apache 2.4'
arch:
- 'linux/amd64'
- 'linux/arm64'
- 'linux/386'
- 'linux/arm/v7'
- 'linux/arm/v6'
# Only run for forks (contributor)
if: ${{ github.event.pull_request.head.repo.fork }}
steps:

# ------------------------------------------------------------
# Setup repository
# ------------------------------------------------------------
- name: "[SETUP] Checkout repository"
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: "[SETUP] Setup QEMU environment"
uses: docker/setup-qemu-action@v1
with:
image: tonistiigi/binfmt:latest
platforms: all

- name: "[SETUP] Determine Docker tag"
id: tag
uses: cytopia/[email protected]

# ------------------------------------------------------------
# Build
# ------------------------------------------------------------
- name: Build
uses: cytopia/[email protected]
with:
command: |
make build ARCH=${ARCH}
env:
ARCH: ${{ matrix.arch }}

# ------------------------------------------------------------
# Test
# ------------------------------------------------------------
- name: "[TEST] Docker Image"
uses: cytopia/[email protected]
with:
command: |
make test ARCH=${ARCH}
env:
ARCH: ${{ matrix.arch }}

- name: "[TEST] Update README"
uses: cytopia/[email protected]
with:
command: |
make update-readme ARCH=${ARCH}
env:
ARCH: ${{ matrix.arch }}
1 change: 1 addition & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@ jobs:
# Lint repository
# ------------------------------------------------------------
- name: Lint workflow
id: vars
run: |
make lint-workflow
Loading

0 comments on commit f1649f7

Please sign in to comment.