-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from docksal/develop
Release 1.2.0
- Loading branch information
Showing
19 changed files
with
288 additions
and
280 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Generates docker images tags for the docker/build-push-action@v2 action depending on the branch/tag. | ||
|
||
declare -a IMAGE_TAGS | ||
|
||
# feature/* => sha-xxxxxxx | ||
# Note: disabled | ||
#if [[ "${GITHUB_REF}" =~ "refs/heads/feature/" ]]; then | ||
# GIT_SHA7=$(echo ${GITHUB_SHA} | cut -c1-7) # Short SHA (7 characters) | ||
# IMAGE_TAGS+=("${IMAGE}:sha-${GIT_SHA7}-${VERSION}") | ||
# IMAGE_TAGS+=("ghcr.io/${IMAGE}:sha-${GIT_SHA7}-${VERSION}") | ||
#fi | ||
|
||
# develop => edge | ||
if [[ "${GITHUB_REF}" == "refs/heads/develop" ]]; then | ||
IMAGE_TAGS+=("${IMAGE}:edge-${VERSION}") | ||
IMAGE_TAGS+=("ghcr.io/${IMAGE}:edge-${VERSION}") | ||
fi | ||
|
||
# master => stable | ||
if [[ "${GITHUB_REF}" == "refs/heads/master" ]]; then | ||
IMAGE_TAGS+=("${IMAGE}:stable-${VERSION}") | ||
IMAGE_TAGS+=("ghcr.io/${IMAGE}:stable-${VERSION}") | ||
fi | ||
|
||
# tags/v1.0.0 => 1.0 | ||
if [[ "${GITHUB_REF}" =~ "refs/tags/" ]]; then | ||
# Extract version parts from release tag | ||
IFS='.' read -a ver_arr <<< "${GITHUB_REF#refs/tags/}" | ||
VERSION_MAJOR=${ver_arr[0]#v*} # 2.7.0 => "2" | ||
VERSION_MINOR=${ver_arr[1]} # "2.7.0" => "7" | ||
IMAGE_TAGS+=("${IMAGE}:stable-${VERSION}") | ||
IMAGE_TAGS+=("${IMAGE}:${VERSION_MAJOR}-${VERSION}") | ||
IMAGE_TAGS+=("${IMAGE}:${VERSION_MAJOR}.${VERSION_MINOR}-${VERSION}") | ||
IMAGE_TAGS+=("ghcr.io/${IMAGE}:stable-${VERSION}") | ||
IMAGE_TAGS+=("ghcr.io/${IMAGE}:${VERSION_MAJOR}-${VERSION}") | ||
IMAGE_TAGS+=("ghcr.io/${IMAGE}:${VERSION_MAJOR}.${VERSION_MINOR}-${VERSION}") | ||
fi | ||
|
||
# Output a comma concatenated list of image tags | ||
IMAGE_TAGS_STR=$(IFS=,; echo "${IMAGE_TAGS[*]}") | ||
echo "${IMAGE_TAGS_STR}" | ||
echo "::set-output name=tags::${IMAGE_TAGS_STR}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
# Build a Docker image and push it to GitHub Container Registry | ||
# See https://github.com/docker/build-push-action/blob/master/.github/workflows/example.yml | ||
|
||
name: Docker Build and Push | ||
|
||
on: | ||
schedule: | ||
- cron: '0 10 * * 0' # everyday sunday at 10am | ||
push: | ||
branches: | ||
- master | ||
- develop | ||
- feature/* | ||
tags: | ||
- 'v*.*.*' | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
jobs: | ||
build-push: | ||
name: Build and Push | ||
runs-on: ubuntu-20.04 | ||
strategy: | ||
fail-fast: false # Don't cancel other jobs if one fails | ||
matrix: | ||
version: | ||
- 10.2 | ||
- 10.3 | ||
- 10.4 | ||
- 10.5 | ||
env: | ||
IMAGE: docksal/mariadb | ||
UPSTREAM_IMAGE: mariadb | ||
VERSION: ${{ matrix.version }} | ||
steps: | ||
- | ||
name: Install prerequisites for tests | ||
run: | | ||
set -xeuo pipefail | ||
sudo apt-get -qq update | ||
# Install cgi-fcgi binary used in tests | ||
sudo apt-get -y --no-install-recommends install libfcgi-bin | ||
# Install bats for tests | ||
git clone https://github.com/bats-core/bats-core.git | ||
cd bats-core | ||
sudo ./install.sh /usr/local | ||
bats -v | ||
- | ||
name: Checkout | ||
uses: actions/checkout@v2 | ||
- | ||
name: Set up QEMU | ||
uses: docker/setup-qemu-action@v1 | ||
- | ||
name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
- | ||
name: Check Docker | ||
run: | | ||
docker version | ||
docker info | ||
- | ||
name: Login to Docker Hub | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
- | ||
name: Login to GitHub Container Registry | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ secrets.GHCR_USERNAME }} | ||
password: ${{ secrets.GHCR_TOKEN }} | ||
- | ||
# Calculates docker image tags for the given build context | ||
# The output is used in build and push step as `tags: ${{ steps.docker_meta.outputs.tags }}` | ||
# See https://github.com/crazy-max/ghaction-docker-meta | ||
name: Docker meta | ||
id: docker_meta | ||
uses: crazy-max/ghaction-docker-meta@v1 | ||
with: | ||
# List of Docker images to use as base name for tags | ||
images: | | ||
${{ env.IMAGE }} | ||
ghcr.io/${{ env.IMAGE }} | ||
tag-sha: true # add git short SHA as Docker tag | ||
- | ||
# Generate image meta information | ||
name: Docker image tags | ||
id: docker_tags | ||
run: make tags | ||
- | ||
# Build for local use + registry cache (ghcr.io) | ||
name: Build and cache image (local) | ||
id: docker_build_local | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
file: ./Dockerfile | ||
build-args: | | ||
UPSTREAM_IMAGE=${{ env.UPSTREAM_IMAGE }} | ||
VERSION=${{ env.VERSION }} | ||
#platforms: linux/amd64,linux/arm64 # Note: cannot use multi-platform with local image caching ("load: true") | ||
tags: ${{ env.IMAGE }}:build-${{ env.VERSION }} | ||
load: true # cache image locally for use by other steps | ||
cache-from: type=registry,ref=ghcr.io/${{ env.DOCKER_IMAGE }}:build-${{ matrix.version }} | ||
cache-to: type=inline # Write the cache metadata into the image configuration | ||
- | ||
# Print image info | ||
name: Docker image info | ||
run: | | ||
set -xeuo pipefail | ||
docker image ls | grep "${{ env.IMAGE }}" | ||
docker image inspect "${{ env.IMAGE }}:build-${{ env.VERSION }}" | ||
- | ||
# Cache image layers in the registry | ||
# This will pick-up the build cache from the local build step | ||
name: Build and push image cache (ghcr.io) | ||
id: docker_build_cache | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
file: ./Dockerfile | ||
build-args: | | ||
UPSTREAM_IMAGE=${{ env.UPSTREAM_IMAGE }} | ||
VERSION=${{ env.VERSION }} | ||
platforms: linux/amd64,linux/arm64 | ||
tags: ghcr.io/${{ env.IMAGE }}:build-${{ env.VERSION }} # Build cache tag in ghcr.io | ||
push: ${{ github.event_name != 'pull_request' }} # Don't push for PRs | ||
cache-to: type=inline # Write the cache metadata into the image configuration | ||
- | ||
# Run tests | ||
name: Test | ||
run: make test | ||
- | ||
# Push final image to the registry | ||
# This will pick-up the build cache from the local build step | ||
name: Build and push image | ||
id: docker_build_push | ||
# Don't run if the list of tags is empty | ||
# Note: using tags from docker_tags (custom) | ||
if: ${{ steps.docker_tags.outputs.tags != '' }} | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
file: ./Dockerfile | ||
build-args: | | ||
UPSTREAM_IMAGE=${{ env.UPSTREAM_IMAGE }} | ||
VERSION=${{ env.VERSION }} | ||
platforms: linux/amd64,linux/arm64 | ||
tags: ${{ steps.docker_tags.outputs.tags }} # Note: using tags from docker_tags (custom script) | ||
labels: ${{ steps.docker_meta.outputs.labels }} # Note: using lables from docker_meta | ||
push: ${{ github.event_name != 'pull_request' }} # Don't push for PRs | ||
cache-to: type=inline # Write the cache metadata into the image configuration |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.