# Gitea Actions workflow for StarPunk # Runs the tests, then builds and pushes container images on version tags. # # The runner has no Docker daemon (that would give workflows root on the # server). Images are built by the rootless BuildKit container next to it, # reached through its socket. name: Build Container on: push: tags: - 'v[0-9]+.[0-9]+.[0-9]+' workflow_dispatch: env: REGISTRY: git.thesatelliteoflove.com BUILDKIT: unix:///run/buildkit/buildkit/buildkitd.sock jobs: build: runs-on: docker steps: - name: Install dependencies run: apk add --no-cache nodejs git docker-cli docker-cli-buildx - name: Checkout uses: actions/checkout@v4 # The automatic Actions token can't log in to the container registry, so # this uses a personal access token with only the write:package scope, # stored as the repository secret REGISTRY_TOKEN. - name: Log in to the Gitea registry run: echo "${{ secrets.REGISTRY_TOKEN }}" | docker login "$REGISTRY" -u "${{ github.repository_owner }}" --password-stdin - name: Use the BuildKit socket run: docker buildx create --name ci --driver remote "$BUILDKIT" --use # Builds the Containerfile's test stage, which runs pytest; a failure # stops the workflow before anything is pushed - name: Run tests run: docker buildx build --target test --progress plain -f Containerfile . - name: Build and push run: | image="$REGISTRY/$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" docker buildx build --push -f Containerfile \ -t "$image:${{ github.ref_name }}" -t "$image:latest" . - name: Clean up if: always() run: | docker buildx rm ci || true docker logout "$REGISTRY" || true