Skip to content

docker

docker #498

Workflow file for this run

name: docker
on:
push:
schedule:
- cron: "0 9 * * *"
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-and-push:
permissions:
packages: write
contents: read
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Get latest release info
id: rel_info
run: |
curl -sSL -o /tmp/rel_info https://codeberg.org/api/v1/repos/eduVPN/proxyguard/releases/latest
echo "PG_REL_TAG=$(jq -r .tag_name /tmp/rel_info)" >> "$GITHUB_OUTPUT"
echo "SOURCE_DATE_EPOCH=$(git log -1 --pretty='%ct')" >> "$GITHUB_OUTPUT"
- name: Docker meta
id: meta
uses: docker/metadata-action@030e881283bb7a6894de51c315a6bfe6a94e05cf # v6.0.0
with:
# list of Docker images to use as base name for tags
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
# generate Docker tags based on the following events/attributes
tags: |
type=semver,pattern={{version}},value=${{ steps.rel_info.outputs.PG_REL_TAG }}
type=semver,pattern={{major}}.{{minor}},value=${{ steps.rel_info.outputs.PG_REL_TAG }}
type=semver,pattern={{major}},value=${{ steps.rel_info.outputs.PG_REL_TAG }}
# set 'created' label fix to commit date to avoid cache busting/changing digests on rebuilds
labels: |
org.opencontainers.image.created={{commit_date 'YYYY-MM-DDTHH:mm:ss.SSS[Z]'}}
org.opencontainers.image.version=${{ steps.rel_info.outputs.PG_REL_TAG }}
org.opencontainers.image.vendor=${{ github.repository_owner }}
org.opencontainers.image.licenses=GPL-3.0,MIT
- name: Login to GHCR
if: github.event_name != 'pull_request'
uses: docker/login-action@b45d80f862d83dbcd57f89517bcf500b2ab88fb2 # v4.0.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a # v4.0.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
- name: Build and push
uses: docker/build-push-action@d08e5c354a6adb9ed34480a06d141179aa583294 # v7.0.0
with:
push: ${{ github.event_name != 'pull_request' && github.ref_name == 'main' }}
build-args: VERSION=${{ steps.rel_info.outputs.PG_REL_TAG }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
provenance: false
env:
SOURCE_DATE_EPOCH: ${{ steps.rel_info.outputs.SOURCE_DATE_EPOCH }}