I created a new public Github repository with a small Go app and a Dockerfile. I’m using the following Github workflow to release my app as a binary and Docker image
name: Release
on:
push:
branches:
- 'main'
permissions:
contents: write
packages: write
jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get next version
id: get_next_version
uses: thenativeweb/[email protected]
- name: Setup Go
if: ${{ steps.get_next_version.outputs.hasNextVersion == 'true' }}
uses: actions/setup-go@v5
with:
go-version: 1.22.x
- name: Setup Git user
if: ${{ steps.get_next_version.outputs.hasNextVersion == 'true' }}
run: |
git config user.name github-actions
git config user.email [email protected]
- name: Create new tag
if: ${{ steps.get_next_version.outputs.hasNextVersion == 'true' }}
run: |
next_version=${{ steps.get_next_version.outputs.version }}
git tag $next_version
git push origin $next_version
- name: Build for platforms
if: ${{ steps.get_next_version.outputs.hasNextVersion == 'true' }}
run: make build-all
- name: Release binaries
if: ${{ steps.get_next_version.outputs.hasNextVersion == 'true' }}
uses: ncipollo/release-action@v1
with:
artifacts: "build/*"
tag: ${{ steps.get_next_version.outputs.version }}
- name: Set up QEMU
if: ${{ steps.get_next_version.outputs.hasNextVersion == 'true' }}
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
if: ${{ steps.get_next_version.outputs.hasNextVersion == 'true' }}
uses: docker/setup-buildx-action@v3
- name: Login to GitHub container registry
if: ${{ steps.get_next_version.outputs.hasNextVersion == 'true' }}
uses: docker/login-action@v3
with:
registry: ghcr.io
username: github-actions
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
if: ${{ steps.get_next_version.outputs.hasNextVersion == 'true' }}
uses: docker/build-push-action@v5
env:
DOCKER_REPOSITORY: ghcr.io/${{ github.repository }}
with:
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ env.DOCKER_REPOSITORY }}:latest,${{ env.DOCKER_REPOSITORY }}:${{steps.get_next_version.outputs.version}}
Releasing new binaries works fine but unfortunately the step
Build and push Docker image
fails. The POST request returns with the HTTP status code Forbidden. This workflow used to work, do I need to fix something to make it work?