Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 4 additions & 21 deletions .github/workflows/build_containers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,8 @@ jobs:
- uses: wimpysworld/nothing-but-nix@main
- uses: cachix/install-nix-action@v31.3.0
- name: Build snapbin image
run: nix build .#snapbin-image && docker load < ./result

- name: Log into registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin

- name: Push image
env:
IMAGE_NAME: snapbin
run: |
IMAGE_ID=ghcr.io/${{ github.repository }}/$IMAGE_NAME
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# Use Docker `latest` tag convention
[ "$VERSION" == "main" ] && VERSION=latest
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_USERNAME: ${{ github.actor }}
GITHUB_REPOSITORY: ${{ github.repository }}
run: nix develop --command build-image.sh
1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@
packages = [
pythonDev
pkgs.poetry
pkgs.skopeo
];
inputsFrom = [
config.process-compose."dev-services".services.outputs.devShell
Expand Down
5 changes: 5 additions & 0 deletions tooling/bin/build-image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash
echo "$GITHUB_TOKEN" | skopeo login ghcr.io --username "$GITHUB_USERNAME" --password-stdin
result=$(nix build .#snapbin-image --no-link --print-out-paths)
# ${variabe,,} converts a string to lowercase
skopeo copy --insecure-policy docker-archive://"$result" docker://"ghcr.io/${GITHUB_REPOSITORY,,}/snapbin:latest"