Skip to content

Commit

Permalink
Publish SemVer-tagged images on tag pushes to main (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronmondal committed Dec 21, 2023
1 parent b12dfb8 commit 34bcd15
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
39 changes: 39 additions & 0 deletions .github/workflows/tagged_image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
name: Create SemVer-tagged OCI image
on:
push:
tags:
- '*'

permissions: read-all

jobs:
publish-image:
runs-on: ubuntu-22.04
permissions:
packages: write
id-token: write
steps:

- name: Checkout
uses: >- # v4.1.1
actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
- name: Install Nix
uses: >- # v7
DeterminateSystems/nix-installer-action@5620eb4af6b562c53e4d4628c0b6e4f9d9ae8612
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Test image
run: |
nix run .#local-image-test
- name: Upload image
run: |
nix run .#publish-ghcr ${{github.ref_name}}
env:
GHCR_REGISTRY: ghcr.io
GHCR_USERNAME: ${{ github.actor }}
GHCR_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
GHCR_IMAGE_NAME: ${{ github.repository }}
4 changes: 3 additions & 1 deletion tools/publish-ghcr.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ pkgs.writeShellScriptBin "publish-ghcr" ''
# nothing would still lead to a new hash. Instead we use the
# derivation hash as the tag so that the tag is reused if the image
# didn't change.
IMAGE_TAG=$(nix eval .#image.imageTag --raw)
#
# If a positional argument is passed it overrides the tag value.
IMAGE_TAG=''${1:-$(nix eval .#image.imageTag --raw)}
TAGGED_IMAGE=''${GHCR_REGISTRY}/''${GHCR_IMAGE_NAME,,}:''${IMAGE_TAG}
Expand Down

0 comments on commit 34bcd15

Please sign in to comment.