build / Build and push image (push) Successful in 1m45s
The automatic token is rejected by the package registry regardless of the permissions the job requests, so the push uses a personal access token scoped to package read and write. The job no longer asks for packages: write, since nothing it does with the automatic token touches the registry.
84 lines
2.1 KiB
YAML
84 lines
2.1 KiB
YAML
name: build
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
tags: ['v*']
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
concurrency:
|
|
group: build-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
env:
|
|
REGISTRY: git.mroberts.dev
|
|
IMAGE: git.mroberts.dev/mroberts/claude-sbx
|
|
REGCTL_VERSION: v0.11.5
|
|
|
|
jobs:
|
|
build:
|
|
name: Build and push image
|
|
runs-on: linux
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
steps:
|
|
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- name: Install regctl
|
|
run: |
|
|
mkdir -p "$HOME/.local/bin"
|
|
curl -fsSL -o "$HOME/.local/bin/regctl" \
|
|
"https://github.com/regclient/regclient/releases/download/${REGCTL_VERSION}/regctl-linux-amd64"
|
|
chmod +x "$HOME/.local/bin/regctl"
|
|
printf '%s\n' "$HOME/.local/bin" >>"$GITHUB_PATH"
|
|
|
|
- name: Resolve tag
|
|
id: tag
|
|
env:
|
|
REF: ${{ github.ref }}
|
|
run: |
|
|
if [[ "$REF" == refs/tags/* ]]; then
|
|
printf 'value=%s\n' "${REF#refs/tags/}" >>"$GITHUB_OUTPUT"
|
|
else
|
|
printf 'value=edge\n' >>"$GITHUB_OUTPUT"
|
|
fi
|
|
|
|
- name: Build
|
|
env:
|
|
TAG: ${{ steps.tag.outputs.value }}
|
|
run: docker build -t "$IMAGE:$TAG" .
|
|
|
|
- name: Export image
|
|
env:
|
|
TAG: ${{ steps.tag.outputs.value }}
|
|
run: docker save "$IMAGE:$TAG" -o image.tar
|
|
|
|
- name: Push
|
|
env:
|
|
TAG: ${{ steps.tag.outputs.value }}
|
|
REGISTRY_USER: ${{ github.actor }}
|
|
# zizmor: ignore[secrets-outside-env]
|
|
REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }}
|
|
run: |
|
|
printf '%s' "$REGISTRY_TOKEN" |
|
|
regctl registry login "$REGISTRY" --user "$REGISTRY_USER" --pass-stdin
|
|
|
|
regctl registry set "$REGISTRY" \
|
|
--blob-chunk 50000000 \
|
|
--blob-max 50000000
|
|
|
|
regctl image import "$IMAGE:$TAG" image.tar
|
|
|
|
- name: Verify
|
|
env:
|
|
TAG: ${{ steps.tag.outputs.value }}
|
|
run: |
|
|
regctl manifest get "$IMAGE:$TAG" >/dev/null
|
|
printf 'Pushed %s:%s\n' "$IMAGE" "$TAG"
|