Skip to content

Build and publish Docker image #41

Build and publish Docker image

Build and publish Docker image #41

Workflow file for this run

name: "Build and publish Docker image"
on:
release:
types: [published]
workflow_dispatch:
env:
REGISTRY: ghcr.io
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v25
with:
github_access_token: ${{ secrets.GITHUB_TOKEN }}
- name: Restore and cache Nix store
uses: nix-community/cache-nix-action@v5
with:
primary-key: nix-${{ runner.os }}-${{ hashFiles('flake.nix') }}
- name: Use Nix to build a Docker image
run: nix build -L '.#docker-image'
- name: Log into registry
uses: docker/[email protected]
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Import image and push
run: |
docker load -i result
docker push $(docker images --format json | jq -r 'select(.Repository == "ghcr.io/typst/package-check") | .Repository + ":" + .Tag')
docker tag $(docker images --format json | jq -r 'select(.Repository == "ghcr.io/typst/package-check") | .Repository + ":" + .Tag') ghcr.io/typst/package-check:latest
docker push ghcr.io/typst/package-check:latest