Cron to rebuild latest #367
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
name: Cron to rebuild latest | |
on: | |
workflow_dispatch: | |
schedule: | |
# rebuild latest regulary - to resolve CVEs in base images | |
- cron: "0 10 * * *" | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
cancel-in-progress: true | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
flavor: ['debian', 'alpine'] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-tags: true | |
filter: blob:none | |
fetch-depth: 0 | |
- name: Checkout last commit | |
id: checkout | |
run: | | |
LAST_TAG=$(git for-each-ref refs/tags --sort=-authordate --format='%(refname:short)' | grep '^[[:digit:]]*\.[[:digit:]]*\.[[:digit:]]$' | head -n1) | |
echo "LAST_TAG: $LAST_TAG" | |
echo "tag=$LAST_TAG" >> "$GITHUB_OUTPUT" | |
git checkout $LAST_TAG | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
# list of Docker images to use as base name for tags | |
images: | | |
ghcr.io/${{ github.repository }} | |
# add flavor to set latest to false and add those with raw values instead | |
flavor: | | |
latest=false | |
prefix= | |
suffix= | |
# generate Docker tags based on the following events/attributes | |
tags: | | |
type=schedule | |
type=raw,value=latest,enable=${{matrix.flavor == 'debian'}} | |
type=raw,value=latest-${{matrix.flavor}} | |
type=semver,pattern={{version}},value=${{ steps.checkout.outputs.tag }},enable=${{matrix.flavor == 'debian'}} | |
type=semver,pattern={{major}}.{{minor}},value=${{ steps.checkout.outputs.tag }},enable=${{matrix.flavor == 'debian'}} | |
type=semver,pattern={{major}},value=${{ steps.checkout.outputs.tag }},enable=${{matrix.flavor == 'debian'}} | |
type=semver,pattern={{version}}-${{matrix.flavor}},value=${{ steps.checkout.outputs.tag }} | |
type=semver,pattern={{major}}.{{minor}}-${{matrix.flavor}},value=${{ steps.checkout.outputs.tag }} | |
type=semver,pattern={{major}}-${{matrix.flavor}},value=${{ steps.checkout.outputs.tag }} | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to GitHub Container Registry | |
if: github.event_name != 'pull_request' | |
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: | |
context: . | |
push: ${{ github.event_name != 'pull_request' }} | |
file: Containerfile.${{ matrix.flavor }} | |
platforms: linux/amd64,linux/arm64/v8${{ matrix.flavor == 'debian' && ',linux/arm/v7' || '' }} | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} |