Add docker workflow permissions to write packages #3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Main branch workflow | |
on: | |
push: | |
branches: | |
- main | |
env: | |
IMAGE_ARCHITECTURES: linux/amd64,linux/arm64 | |
IMAGE_REGISTRY: ghcr.io | |
DOCKERFILE_PATH: build/Dockerfile | |
jobs: | |
publish-release: | |
name: Publish Release | |
runs-on: ubuntu-latest | |
outputs: | |
new_tag: ${{ steps.tag_version.outputs.new_tag }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Bump version and push tag | |
id: tag_version | |
uses: mathieudutour/[email protected] | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Create a GitHub release | |
uses: ncipollo/release-action@v1 | |
with: | |
tag: ${{ steps.tag_version.outputs.new_tag }} | |
name: Release ${{ steps.tag_version.outputs.new_tag }} | |
body: ${{ steps.tag_version.outputs.changelog }} | |
docker-build-push: | |
name: Build Push Docker Image | |
runs-on: ubuntu-latest | |
needs: publish-release | |
permissions: | |
id-token: write | |
packages: write | |
contents: read | |
env: | |
IMAGE_TAG: ${{ needs.publish-release.outputs.new_tag }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
with: | |
platforms: ${{ env.IMAGE_ARCHITECTURES }} | |
- name: Log in to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.IMAGE_REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
file: ${{ env.DOCKERFILE_PATH }} | |
push: true | |
platforms: ${{ env.IMAGE_ARCHITECTURES }} | |
tags: | | |
${{ env.IMAGE_REGISTRY }}/${{ github.repository }}:${{ env.IMAGE_TAG }} | |
${{ env.IMAGE_REGISTRY }}/${{ github.repository }}:latest |