Skip to content

Commit 203c15b

Browse files
committed
1 parent 1ae2cc3 commit 203c15b

File tree

1 file changed

+29
-16
lines changed

1 file changed

+29
-16
lines changed

.github/workflows/test-build-publish.yaml

+29-16
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,39 @@ on:
33
release:
44
types:
55
- created
6+
env:
7+
REGISTRY: ghcr.io
8+
IMAGE_NAME: ${{ github.repository }}
69
jobs:
710
test-build:
811
runs-on: ubuntu-latest
12+
permissions:
13+
contents: read
14+
packages: write
915
steps:
10-
- uses: actions/checkout@v2
11-
- name: Build container (which includes running tests)
12-
run: docker build .
13-
- name: Log into registry
14-
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin
15-
- name: Push image
16-
run: |
17-
IMAGE_ID=docker.pkg.github.com/${{ github.repository }}
18-
# Strip git ref prefix from version
19-
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
20-
# Use Docker `latest` tag convention
21-
[ "$VERSION" == "master" ] && VERSION=latest
22-
echo IMAGE_ID=$IMAGE_ID
23-
echo VERSION=$VERSION
24-
docker tag image $IMAGE_ID:$VERSION
25-
docker push $IMAGE_ID:$VERSION
16+
- uses: actions/checkout@v3
17+
18+
- name: Log in to the Container registry
19+
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
20+
with:
21+
registry: ${{ env.REGISTRY }}
22+
username: ${{ github.actor }}
23+
password: ${{ secrets.GITHUB_TOKEN }}
24+
25+
- name: Extract metadata (tags, labels) for Docker
26+
id: meta
27+
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
28+
with:
29+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
30+
31+
- name: Build and push Docker image
32+
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
33+
with:
34+
context: .
35+
push: true
36+
tags: ${{ steps.meta.outputs.tags }}
37+
labels: ${{ steps.meta.outputs.labels }}
38+
2639
release-notes:
2740
needs: test-build
2841
if: ${{ github.event_name == 'release' }}

0 commit comments

Comments
 (0)