Skip to content

Commit

Permalink
ci: also publish to GitHub Packages
Browse files Browse the repository at this point in the history
Allow Github users to not have another external dependency.
  • Loading branch information
zimbatm committed Jul 23, 2024
1 parent 5a36736 commit ce07f76
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
27 changes: 24 additions & 3 deletions .github/workflows/nix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
schedule:
# Run once per day
- cron: '0 0 * * *'

jobs:
build:
strategy:
Expand All @@ -18,9 +19,19 @@ jobs:
- nixos-unstable
- nixos-24.05
system:
- x86_64-linux
- aarch64-linux
- x86_64-linux
registry:
- name: ghcr.io
image_prefix: nix-community/docker-nixpkgs
- name: docker.io
image_prefix: nixpkgs
runs-on: ubuntu-latest

permissions:
contents: read
packages: write

steps:
- uses: actions/checkout@v4
- name: Set up QEMU
Expand All @@ -33,13 +44,23 @@ jobs:
extra-platforms = aarch64-linux
- uses: DeterminateSystems/magic-nix-cache-action@main

- name: Log in to the Container registry
if: "${{ matrix.registry.name == 'ghcr.io' }}"
uses: docker/[email protected]
with:
registry: ${{ matrix.registry.name }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- run: nix-shell --run ./ci.sh
env:
CI_REGISTRY_AUTH: '${{ secrets.REGISTRY_AUTH }}'
CI_PROJECT_PATH: '${{ matrix.registry.image_prefix }}'
CI_REGISTRY: '${{ matrix.registry.name }}'
CI_REGISTRY_AUTH: "${{ matrix.registry.name == 'ghcr.io' && '${{ github.action }}:${{ secrets.GITHUB_TOKEN }}' || secrets.REGISTRY_AUTH }}"
NIXPKGS_CHANNEL: '${{ matrix.channel }}'
NIX_SYSTEM_NAME: '${{ matrix.system }}'

push-manifest:
push-manifest-to-docker-hub:
needs: [build]
strategy:
fail-fast: false
Expand Down
5 changes: 0 additions & 5 deletions ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,3 @@ fi

banner "docker push"
./push-all "$registry" "$image_prefix" "$image_tag"

if [[ -n "${registry_auth}" && $registry = *docker.io ]]; then
banner "docker metadata update"
./dockerhub-metadata "$registry_auth" "$image_prefix"
fi

0 comments on commit ce07f76

Please sign in to comment.