Skip to content

0.1.0

0.1.0 #1

Workflow file for this run

name: Registry
# Put 'on' in quotes to avoid YAML parsing error
"on":
# Run on new releases
release:
types:
- published
jobs:
registry:
name: Publish Docker image to GitHub registry
# Pin version of Ubuntu to avoid breaking changes
runs-on: ubuntu-22.04
# Use reasonable timeout to avoid stuck workflows
timeout-minutes: 30
env:
NIX_CACHE_DIR: /home/runner/.nixcache/
permissions:
# Needed to checkout code
contents: read
# Needed to push to registry
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v4.1.1
- name: Setup Nix cache
uses: actions/cache@v4.0.1
id: cache-nix
with:
path: ${{ env.NIX_CACHE_DIR }}
key: registry-nix
- name: Install Nix
uses: cachix/install-nix-action@v26
with:
github_access_token: ${{ github.token }}
install_url: https://releases.nixos.org/nix/nix-2.20.5/install
# See: https://github.com/cachix/install-nix-action/issues/56
- name: Import Nix store cache
if: steps.cache-nix.outputs.cache-hit == 'true'
run: >
nix-store
--import
< ${{ env.NIX_CACHE_DIR }}/archive.nar
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3.1.0
- name: Log in to the Container registry
uses: docker/login-action@v3.0.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build Docker image
# yamllint disable rule:line-length
run: >
nix
develop
.#build
--command
--
task
build
--
--image-name
'ghcr.io/radio-aktywne/devcontainers/flux:latest'
--image-name
'ghcr.io/radio-aktywne/devcontainers/flux:${{ github.event.release.tag_name }}'
--cache-from
'type=gha,scope=${{ github.workflow }}'
--cache-to
'type=gha,mode=max,scope=${{ github.workflow }}'
--push
true
# yamllint enable rule:line-length
- name: Export Nix store cache
if: "!cancelled()"
run: >
mkdir
--parents
${{ env.NIX_CACHE_DIR }}
&&
nix-store
--export $(find /nix/store/ -maxdepth 1 -name '*-*')
> ${{ env.NIX_CACHE_DIR }}/archive.nar