Skip to content

Commit

Permalink
Add docker to release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaelzoellner committed Jan 2, 2024
1 parent 66efdc6 commit ad9eee9
Showing 1 changed file with 36 additions and 1 deletion.
37 changes: 36 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: release
on:
# Test that it works on pull_request; goreleaser goes into snapshot mode if not a tag.
# Test that it works on pull_request;
# goreleaser goes into snapshot mode if not a tag;
# docker image will be built but not pushed for pull requests.
pull_request:
push:
tags:
Expand All @@ -9,6 +11,14 @@ on:
permissions:
# goreleaser writes to the releases api
contents: write
# docker writes packages to container registry
packages: write

env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}

jobs:
goreleaser:
Expand All @@ -32,3 +42,28 @@ jobs:
args: release --rm-dist ${{ env.flags }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
docker-release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- run: git fetch --force --tags
- name: Log in to the Container registry
uses: docker/login-action@v3.0.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5.4.0
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build and push Docker image (image is not pushed on pull request)
uses: docker/build-push-action@v5.1.0
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

0 comments on commit ad9eee9

Please sign in to comment.