Skip to content

Cron to rebuild latest #35

Cron to rebuild latest

Cron to rebuild latest #35

Workflow file for this run

name: Cron to rebuild latest
on:
workflow_dispatch:
schedule:
# rebuild latest regulary - to resolve CVEs in base images
- cron: "0 10 * * *"
jobs:
build:
runs-on: ubuntu-latest
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 }}
# generate Docker tags based on the following events/attributes
tags: |
type=schedule
type=raw,value=latest,enable={{is_default_branch}}
type=semver,pattern={{version}},value=${{ steps.checkout.outputs.tag }}
type=semver,pattern={{major}}.{{minor}},value=${{ steps.checkout.outputs.tag }}
type=semver,pattern={{major}},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
platforms: linux/amd64,linux/arm64/v8,linux/arm/v7
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}