use --substitute-on-destination for caching #8
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: Publish | |
on: | |
push: | |
branches: | |
- main | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ${{ github.repository }} | |
jobs: | |
push: | |
name: push container | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
outputs: | |
image: ${{ steps.push.outputs.image }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: DeterminateSystems/nix-installer-action@v9 | |
- uses: DeterminateSystems/magic-nix-cache-action@v3 | |
- uses: nixbuild/nixbuild-action@v19 | |
with: | |
nixbuild_token: ${{ secrets.NIXBUILD_TOKEN }} | |
generate_summary_for: 'workflow' | |
- name: Log into the container registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: build and load container | |
run: | | |
STORE_PATH="$( | |
nix build \ | |
--json \ | |
--print-build-logs \ | |
--builders "" \ | |
--max-jobs 2 \ | |
--eval-store auto \ | |
--store ssh-ng://eu.nixbuild.net \ | |
--system x86_64-linux \ | |
.#container | \ | |
jq -r '.[0].outputs.out' | |
)" | |
nix copy \ | |
--from ssh-ng://eu.nixbuild.net \ | |
--substitute-on-destination \ | |
"$STORE_PATH" | |
"$STORE_PATH" | docker load | |
- name: push container | |
id: push | |
run: | | |
REPO="ghcr.io/bytes-zone/mazes" | |
TAG="$(docker images "$REPO" --format "{{.Tag}}")" | |
FINAL_NAME="$REPO:$TAG" | |
docker push "$FINAL_NAME" | |
echo "image=$FINAL_NAME" >> "$GITHUB_OUTPUT" | |
publish: | |
name: publish manifest | |
runs-on: ubuntu-latest | |
environment: production | |
needs: push | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
repository: bytes-zone/infrastructure.v2 | |
ref: main | |
ssh-key: ${{ secrets.DEPLOY_KEY }} | |
- name: update manifest | |
run: | | |
./update-job-image-gha.sh mazes ${{ needs.push.outputs.image }} |