Skip to content

Commit 9e6ba92

Browse files
authored
Merge pull request #771 from regiocom/main
Publish docker image to GitHub Container Registry
2 parents 5622bb9 + 2a4c624 commit 9e6ba92

1 file changed

Lines changed: 37 additions & 1 deletion

File tree

.github/workflows/release.yml

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
name: release
22
on:
3-
# Test that it works on pull_request or merge group; goreleaser goes into snapshot mode if not a tag.
3+
# Test that it works on pull_request or merge group;
4+
# goreleaser goes into snapshot mode if not a tag;
5+
# docker image will be built but not pushed for pull requests or merge group events.
46
pull_request:
57
merge_group:
68
push:
79
tags:
810
- v*
911

12+
env:
13+
# Use docker.io for Docker Hub if empty
14+
REGISTRY: ghcr.io
15+
# github.repository as <account>/<repo>
16+
IMAGE_NAME: ${{ github.repository }}
17+
1018
jobs:
1119
goreleaser:
1220
runs-on: ubuntu-latest
@@ -32,3 +40,31 @@ jobs:
3240
args: release --rm-dist ${{ env.flags }}
3341
env:
3442
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43+
docker-release:
44+
runs-on: ubuntu-latest
45+
permissions:
46+
# docker writes packages to container registry
47+
packages: write
48+
steps:
49+
- uses: actions/checkout@v4
50+
with:
51+
fetch-depth: 0
52+
- run: git fetch --force --tags
53+
- name: Log in to the Container registry
54+
uses: docker/login-action@v3.0.0
55+
with:
56+
registry: ${{ env.REGISTRY }}
57+
username: ${{ github.actor }}
58+
password: ${{ secrets.GITHUB_TOKEN }}
59+
- name: Extract metadata (tags, labels) for Docker
60+
id: meta
61+
uses: docker/metadata-action@v5.4.0
62+
with:
63+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
64+
- name: Build and push Docker image (image is not pushed on pull request)
65+
uses: docker/build-push-action@v5.1.0
66+
with:
67+
context: .
68+
push: ${{ github.event_name != 'pull_request' && github.event_name != 'merge_group' }}
69+
tags: ${{ steps.meta.outputs.tags }}
70+
labels: ${{ steps.meta.outputs.labels }}

0 commit comments

Comments
 (0)