name: build-and-push on: push: branches: [main] tags: ['v*'] permissions: contents: read packages: write jobs: docker: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 - name: Lint and test # Built, not mounted: this job runs in a container, so a host bind mount # of $PWD arrives empty. A failure here stops the image being built. run: docker build -f Dockerfile.check -t printhive-check . - name: Log in to the Forgejo container registry # REGISTRY_TOKEN = a Forgejo access token with write:package scope, added # as a repo Actions secret. The auto GITHUB_TOKEN can't push packages. run: echo "${{ secrets.REGISTRY_TOKEN }}" | docker login git.plexultra.com -u "${{ github.repository_owner }}" --password-stdin - name: Build and push image run: | IMAGE="git.plexultra.com/${{ github.repository }}" SHA="${{ github.sha }}" docker build -t "$IMAGE:latest" -t "$IMAGE:${SHA:0:12}" . docker push "$IMAGE:latest" docker push "$IMAGE:${SHA:0:12}"