Skip to content

Another Pre-Release test #15

Another Pre-Release test

Another Pre-Release test #15

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
name: Publish Docker image
on:
push:
tags:
- '*-dev.*'
release:
# `published` type is triggered for both `latest` and `prerelease` releases
types: [published]
jobs:
push_to_registry:
name: Push Docker image to Docker Hub
runs-on: ubuntu-22.04
steps:
- name: Check out the repo
uses: actions/checkout@v3
# Buildx allows for advanced Docker build features like multi-platform builds and layer caching
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to Docker Hub
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
# Extract metadata for app image
- name: Extract metadata (tags) for Docker app Image
id: meta_app
uses: docker/metadata-action@v3
with:
images: aaronskiba/roadmap
flavor: |
latest=false
suffix=-app
# conditional tagging logic based on event type and git tag structure:
# if (prerelease && git tag pattern matches portage-(\d+\.\d+\.\d+-rc.\d+)$ pattern):
# - tag image as \d+\.\d+\.\d+-rc.\d+-app
# else if (latest stable release && git tag pattern matches portage-(\d+\.\d+\.\d+)$ pattern):
# - tag image as \d+\.\d+\.\d+\d+-app
# else if (push event && git tag pattern matches portage-(\d+\.\d+\.\d+-dev.\d+) pattern):
# - tag image as \d+\.\d+\.\d+-dev.\d+-app
tags: |
${{ github.event.release.prerelease &&
'type=match,pattern=.+portage-(\d+\.\d+\.\d+-rc.\d+)$,group=1' ||
(github.event_name == 'release' && !github.event.release.prerelease &&
'type=match,pattern=.+portage-(\d+\.\d+\.\d+)$,group=1') ||
(github.event_name == 'push' &&
'type=match,pattern=.+portage-(\d+\.\d+\.\d+-dev.\d+),group=1') }}
# Extract metadata for assets image
- name: Extract metadata (tags) for Docker assets image
id: meta_assets
uses: docker/metadata-action@v3
with:
images: aaronskiba/roadmap
flavor: |
latest=false
suffix=-assets
# conditional tagging logic based on event type and git tag structure:
# if (prerelease && git tag pattern matches portage-(\d+\.\d+\.\d+-rc.\d+)$ pattern):
# - tag image as \d+\.\d+\.\d+-rc.\d+-assets
# else if (latest stable release && git tag pattern matches portage-(\d+\.\d+\.\d+)$ pattern):
# - tag image as \d+\.\d+\.\d+\d+-assets
# else if (push event && git tag pattern matches portage-(\d+\.\d+\.\d+-dev.\d+) pattern):
# - tag image as \d+\.\d+\.\d+-dev.\d+-assets
tags: |
${{ github.event.release.prerelease &&
'type=match,pattern=.+portage-(\d+\.\d+\.\d+-rc.\d+)$,group=1' ||
(github.event_name == 'release' && !github.event.release.prerelease &&
'type=match,pattern=.+portage-(\d+\.\d+\.\d+)$,group=1') ||
(github.event_name == 'push' &&
'type=match,pattern=.+portage-(\d+\.\d+\.\d+-dev.\d+),group=1') }}
- name: Build and push the app stage image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
file: Dockerfile.production
target: app
push: true
tags: |
${{ steps.meta_app.outputs.tags }}
# Fetch existing build cache from Docker Hub, if available
cache-from: type=registry,ref=aaronskiba/roadmap:build-cache-app
# Push the updated build cache to Docker Hub
cache-to: type=registry,ref=aaronskiba/roadmap:build-cache-app,mode=max
- name: Build and push the assets stage image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
file: Dockerfile.production
target: assets
push: true
tags: |
${{ steps.meta_assets.outputs.tags }}
# Fetch existing build cache from Docker Hub, if available
# else, built `app` layer will be used as a fallback cache
cache-from: type=registry,ref=aaronskiba/roadmap:build-cache-assets
# Push the updated build cache to Docker Hub
cache-to: type=registry,ref=aaronskiba/roadmap:build-cache-assets,mode=max