modernise #6
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
# vim: ts=2 sw=2: | |
name: Docker Build and Deploy | |
on: | |
workflow_dispatch: | |
pull_request: | |
branches: | |
- master | |
push: | |
# Publish `master` as Docker `dev` image. | |
branches: | |
- master | |
# Publish `v*` tags as x.x.x images and as `latest`. | |
tags: | |
- v* | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
docker: | |
name: Build and push docker images | |
runs-on: ubuntu-latest | |
permissions: | |
packages: write | |
steps: | |
- name: Checkout | |
uses: classabbyamp/treeless-checkout-action@v1 | |
- name: Write ref to file | |
if: ${{ github.event_name != 'pull_request' }} | |
run: git rev-list -n 1 $GITHUB_REF > ./git_commit | |
- name: Docker metadata | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: | | |
ghcr.io/${{ github.repository }} | |
tags: | | |
type=sha,prefix= | |
type=raw,value=dev,enable={{is_default_branch}} | |
type=match,pattern=v(.*),group=1 | |
labels: | | |
org.opencontainers.image.authors=classabbyamp | |
org.opencontainers.image.url=https://github.com/classabbyamp/qsl-generator | |
org.opencontainers.image.source=https://github.com/${{ github.repository }} | |
org.opencontainers.image.vendor=classabbyamp | |
org.opencontainers.image.title=qsl-generator | |
org.opencontainers.image.description=flask webapp to generate QSL card designs | |
org.opencontainers.image.licenses=MIT | |
- name: Login to Github Container Registry | |
uses: docker/login-action@v1 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} |