Update CHANGELOG.md #138
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
name: Docker Build | |
on: [push] | |
env: | |
DOCKER_REGISTRY_IMAGE: ghcr.io/fortrabbit/craft-copy | |
DOCKER_REGISTRY_IMAGE_DEV: ghcr.io/fortrabbit/craft-copy-dev | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-18.04 | |
defaults: | |
run: | |
working-directory: ./docker | |
strategy: | |
fail-fast: false | |
matrix: | |
craft_image_tag: ['7.4', '8.0', '8.1'] | |
steps: | |
- uses: actions/checkout@v1 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v1 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Slugify branch/tag name | |
shell: bash | |
run: echo "##[set-output name=slug;]$(echo $GITHUB_REF | sed -E 's/refs\/(heads|tags)\///g' | iconv -t ascii//TRANSLIT | sed -E 's/[^a-zA-Z0-9]+/-/g' | sed -E 's/^-+|-+$//g' | tr A-Z a-z)" | |
id: branch_slug | |
# Usage: ${{ steps.branch_slug.outputs.slug }} | |
- name: Build docker image | |
working-directory: ./docker | |
run: | | |
docker build \ | |
--build-arg CRAFT_IMAGE_TAG="${{ matrix.craft_image_tag }}" \ | |
--tag $DOCKER_REGISTRY_IMAGE:${{ matrix.craft_image_tag }} \ | |
--tag $DOCKER_REGISTRY_IMAGE:${{ matrix.craft_image_tag }}_${{ steps.branch_slug.outputs.slug }} \ | |
--tag $DOCKER_REGISTRY_IMAGE_DEV:${{ matrix.craft_image_tag }}_${{ steps.branch_slug.outputs.slug }} \ | |
. | |
# Only publish main image (:8.0) on tag push matching "1.0.5" format | |
# https://stackoverflow.com/questions/58862864/github-actions-ci-conditional-regex | |
- name: Check if we are on a semantic git tag | |
id: check-tag | |
run: | | |
if [[ ${{ github.event.ref }} =~ ^refs/tags/[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | |
echo ::set-output name=match::true | |
fi | |
# Dev image will contain all builds from all branches | |
# ghcr.io/fortrabbit/craft-copy-dev:8.0_main | |
# ghcr.io/fortrabbit/craft-copy-dev:8.0_feature-branch | |
- name: Publish dev image | |
if: steps.check-tag.outputs.match != 'true' | |
run: | | |
docker push $DOCKER_REGISTRY_IMAGE_DEV:${{ matrix.craft_image_tag }}_${{ steps.branch_slug.outputs.slug }} | |
# Main image will contain only builds from semantic tags | |
# ghcr.io/fortrabbit/craft-copy:8.0 - removed push to not break old installs of craft-copy that depend on old version of the image | |
# ghcr.io/fortrabbit/craft-copy:8.0_1.2.3 | |
- name: Publish main image | |
if: steps.check-tag.outputs.match == 'true' | |
run: | | |
docker push $DOCKER_REGISTRY_IMAGE:${{ matrix.craft_image_tag }}_${{ steps.branch_slug.outputs.slug }} |