Skip to content

ci: update workflow to latest #34

ci: update workflow to latest

ci: update workflow to latest #34

Workflow file for this run

name: Build
on:
push:
branches:
- master
pull_request:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build:
runs-on: ubuntu-24.04
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Determine tag
id: tag-determiner
env:
PR_NUM: ${{ github.event.pull_request.number }}
run: |
SECONDS_IN_YEAR=$(($(date +%s) - $(date +%s --date="$(date +%Y)-01-01 00:00:00 UTC")))
# Seconds in hex padded to 7 digits
SECONDS_HEX=$(printf "%.7x\n" ${SECONDS_IN_YEAR})
# Replace slashes in refname since not supported in image tags
REF_NAME=$(echo ${GITHUB_REF_NAME} | sed -e 's~/~-~g')
if [ -n "${PR_NUM}" ]
then
REF_NAME=pr-${PR_NUM}
fi
echo "tag-name=${REF_NAME}-$(date +%Y)-${SECONDS_HEX}" >> $GITHUB_OUTPUT
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.tag-determiner.outputs.tag-name }}