Skip to content

Publish image

Publish image #68

Workflow file for this run

---
name: Publish image
on: workflow_dispatch
permissions:
contents: read
packages: write
jobs:
build_and_push:
name: Build and Push
runs-on: ubuntu-latest
env:
ZMREL: 2023.2-1
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Register snapshot tag
run: echo "SNAPSHOT=snapshot-$(date --utc +%Y%m%d%H%M%S)" >> "$GITHUB_ENV"
- name: Register non-main test tags
if: github.ref != 'refs/heads/main'
run: |
GRENEN=${GITHUB_REF#refs/heads/}
echo "BRANCH=${GRENEN//[^a-zA-Z0-9]/-}" >> "$GITHUB_ENV"
echo "RELEASE=test-$ZMREL" >> "$GITHUB_ENV"
- name: Register main release tags
if: github.ref == 'refs/heads/main'
run: |
echo "BRANCH=latest" >> "$GITHUB_ENV"
echo "RELEASE=$ZMREL" >> "$GITHUB_ENV"
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
with:
pull: true
push: true
tags: |
ghcr.io/${{ github.repository_owner }}/zonemaster-cli:${{ env.SNAPSHOT }}
ghcr.io/${{ github.repository_owner }}/zonemaster-cli:${{ env.BRANCH }}
ghcr.io/${{ github.repository_owner }}/zonemaster-cli:${{ env.RELEASE }}