Skip to content

Cache to registry

Cache to registry #12

Workflow file for this run

name: Build & deploy
env:
# Change this to upload the built image to your own organization.
docker_tag: "ghcr.io/fyysikkokilta/ilmomasiina"
# Change these to customize your build.
branding_header_title_text: "FK-Ilmomasiina"
branding_header_title_text_short: "FK-Ilmo"
branding_footer_gdpr_text: "Tietosuoja/GDPR"
branding_footer_gdpr_link: "https://drive.google.com/drive/folders/12VBoHzXG7vEYGul87egYQZ3QN_-CKpBa"
branding_footer_home_text: "fyysikkokilta.fi"
branding_footer_home_link: "https://fyysikkokilta.fi"
branding_login_placeholder_email: "it@fyysikkokilta.fi"
on:
push:
branches:
- main
jobs:
lint:
name: Lint & type-check
uses: ./.github/workflows/lint-test.yml
docker:
name: Push Docker image to GitHub Packages
needs: [lint]
runs-on: blacksmith-4vcpu-ubuntu-2404
permissions:
packages: write
contents: read
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Generate Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.docker_tag }}
flavor: |
latest=${{ github.ref == 'refs/heads/main' }}
tags: |
type=semver,pattern={{version}},enable=${{ github.ref_type == 'tag' }}
type=semver,pattern={{major}}.{{minor}},enable=${{ github.ref_type == 'tag' }}
type=ref,event=branch,enable=${{ github.ref_type == 'branch' }}
type=sha
- name: Get version tag
id: get-version
run: echo "version=$(git describe --always --tags)" >> "$GITHUB_OUTPUT"
- name: Push to GitHub Packages
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
# Customize your build here
build-args: |
BRANDING_HEADER_TITLE_TEXT=${{ env.branding_header_title_text }}
BRANDING_HEADER_TITLE_TEXT_SHORT=${{ env.branding_header_title_text_short }}
BRANDING_FOOTER_GDPR_TEXT=${{ env.branding_footer_gdpr_text }}
BRANDING_FOOTER_GDPR_LINK=${{ env.branding_footer_gdpr_link }}
BRANDING_FOOTER_HOME_TEXT=${{ env.branding_footer_home_text }}
BRANDING_FOOTER_HOME_LINK=${{ env.branding_footer_home_link }}
BRANDING_LOGIN_PLACEHOLDER_EMAIL=${{ env.branding_login_placeholder_email }}
VERSION=${{steps.get-version.outputs.version}}
cache-from: type=registry,ref=ghcr.io/fyysikkokilta/ilmomasiina:buildcache
cache-to: type=registry,ref=ghcr.io/fyysikkokilta/ilmomasiina:buildcache,mode=max
outputs:
tag: ${{ steps.meta.outputs.version }}