Skip to content

Scheduled republishing #106

Scheduled republishing

Scheduled republishing #106

name: Scheduled republishing
on:
schedule:
- cron: "0 0 * * 2" # at 00:00 on Tuesday
workflow_dispatch:
inputs:
reason:
description: 'Reason'
required: false
default: 'Manual trigger'
jobs:
publish-almalinux:
name: Publish AlmaLinux
runs-on: ubuntu-latest
strategy:
matrix:
tag: [v1] # keep the list of major tags updated
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
# rebuild and publish `latest/YYYYMMDD`` from main branch
- name: Set 'latest' tags for Docker images
id: meta-latest
uses: docker/metadata-action@v4
with:
images: registry.cern.ch/${{ github.repository_owner }}/almalinux
tags: |
type=raw,value={{date 'YYYYMMDD'}}
type=schedule,pattern={{date 'YYYYMMDD'}}
flavor: |
latest=true
- name: Publish AlmaLinux latest
uses: ./.github/actions/publish-almalinux
with:
registry-username: ${{ secrets.CERN_REGISTRY_USERNAME }}
registry-password: ${{ secrets.CERN_REGISTRY_PASSWORD }}
docker-tags: ${{ steps.meta-latest.outputs.tags }}
docker-labels: ${{ steps.meta-latest.outputs.labels }}
# rebuild and publish `tags`
- name: Get latest tag starting with ${{ matrix.tag }}
run: echo "TAG=$(git tag -l --sort -version:refname | head -n 1 | grep -o '^${{ matrix.tag }}.*')" >> $GITHUB_ENV
- name: Extract semver
run: |
if [[ "${{ env.TAG }}" =~ ^v([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
# BASH_REMATCH contains the results of the most recent pattern match using the =~ operator
MAJOR=${BASH_REMATCH[1]}
MINOR=${BASH_REMATCH[2]}
PATCH=${BASH_REMATCH[3]}
VERSION=$MAJOR.$MINOR.$PATCH
echo "SemVer: major $MAJOR, minor $MINOR, patch: $PATCH, version: $VERSION"
echo "MAJOR=$MAJOR" >> $GITHUB_ENV
echo "MINOR=$MINOR" >> $GITHUB_ENV
echo "PATCH=$PATCH" >> $GITHUB_ENV
echo "VERSION=$MAJOR.$MINOR.$PATCH" >> $GITHUB_ENV
else
echo "Error: tag ${{ env.TAG }} format is incorrect. Must be in the form v<major>.<minor>.<patch>." >&2
exit 1
fi
- name: Checkout tag ${{ env.TAG }}
uses: actions/checkout@v4
with:
ref: ${{ env.TAG }}
- name: Set 'git' tags for Docker images
id: meta-git
uses: docker/metadata-action@v4
with:
images: registry.cern.ch/${{ github.repository_owner }}/almalinux
tags: |
type=raw,value=${{ env.MAJOR }}
type=raw,value=${{ env.MAJOR }}.${{ env.MINOR }}
type=raw,value=${{ env.MAJOR }}.${{ env.MINOR }}.${{ env.PATCH }}
type=raw,value=${{ env.VERSION }}
- name: Publish AlmaLinux tags ${{ env.TAG }}
uses: ./.github/actions/publish-almalinux
with:
registry-username: ${{ secrets.CERN_REGISTRY_USERNAME }}
registry-password: ${{ secrets.CERN_REGISTRY_PASSWORD }}
docker-tags: ${{ steps.meta-git.outputs.tags }}
docker-labels: ${{ steps.meta-git.outputs.labels }}