Skip to content

Commit bb48d57

Browse files
committed
Use skopeo for loading the image
1 parent 94e9c0e commit bb48d57

File tree

3 files changed

+10
-21
lines changed

3 files changed

+10
-21
lines changed

.github/workflows/build_containers.yml

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,8 @@ jobs:
1111
- uses: wimpysworld/nothing-but-nix@main
1212
- uses: cachix/install-nix-action@v31.3.0
1313
- name: Build snapbin image
14-
run: nix build .#snapbin-image && docker load < ./result
15-
16-
- name: Log into registry
17-
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
18-
19-
- name: Push image
2014
env:
21-
IMAGE_NAME: snapbin
22-
run: |
23-
IMAGE_ID=ghcr.io/${{ github.repository }}/$IMAGE_NAME
24-
# Change all uppercase to lowercase
25-
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
26-
# Strip git ref prefix from version
27-
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
28-
# Strip "v" prefix from tag name
29-
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
30-
# Use Docker `latest` tag convention
31-
[ "$VERSION" == "main" ] && VERSION=latest
32-
echo IMAGE_ID=$IMAGE_ID
33-
echo VERSION=$VERSION
34-
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
35-
docker push $IMAGE_ID:$VERSION
15+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
16+
GITHUB_USERNAME: ${{ github.actor }}
17+
GITHUB_REPOSITORY: ${{ github.repository }}
18+
run: nix develop --command build-image.sh

flake.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@
150150
packages = [
151151
pythonDev
152152
pkgs.poetry
153+
pkgs.skopeo
153154
];
154155
inputsFrom = [
155156
config.process-compose."dev-services".services.outputs.devShell

tooling/bin/build-image.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env bash
2+
echo "$GITHUB_TOKEN" | skopeo login ghcr.io --username "$GITHUB_USERNAME" --password-stdin
3+
result=$(nix build .#snapbin-image --no-link --print-out-paths)
4+
# ${variabe,,} converts a string to lowercase
5+
skopeo copy --insecure-policy docker-archive://"$result" docker://"ghcr.io/${GITHUB_REPOSITORY,,}/snapbin:latest"

0 commit comments

Comments
 (0)