Skip to content

Commit 1c6d29b

Browse files
committed
chore(ci): use gha to publish docker images
Signed-off-by: Chris Gianelloni <cgianelloni@applause.com>
1 parent 1252999 commit 1c6d29b

File tree

1 file changed

+81
-0
lines changed

1 file changed

+81
-0
lines changed
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: publish-docker-images
2+
3+
on:
4+
push:
5+
branches: ['master']
6+
tags: ['v*.*.*']
7+
8+
concurrency: ${{ github.ref }}
9+
10+
env:
11+
IMAGE_NAME: applause/metronomikon
12+
13+
jobs:
14+
build-and-push-image:
15+
runs-on: ubuntu-latest
16+
permissions:
17+
contents: read
18+
packages: write
19+
steps:
20+
- uses: actions/checkout@v2
21+
- name: qemu
22+
uses: docker/setup-qemu-action@v2
23+
- uses: docker/setup-buildx-action@v2
24+
- name: Login to Docker Hub
25+
uses: docker/login-action@v2
26+
with:
27+
username: ${{ secrets.DOCKER_HUB_USERNAME }}
28+
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
29+
- id: meta
30+
uses: docker/metadata-action@v4
31+
with:
32+
images: |
33+
${{ env.IMAGE_NAME }}
34+
tags: |
35+
# Only version, no revision
36+
type=match,pattern=v(.*)-(.*),group=1
37+
# branch
38+
type=ref,event=branch
39+
# semver
40+
type=semver,pattern={{version}}
41+
- name: push
42+
uses: docker/build-push-action@v3
43+
with:
44+
context: .
45+
push: true
46+
platforms: linux/amd64,linux/arm64
47+
tags: ${{ steps.meta.outputs.tags }}
48+
labels: ${{ steps.meta.outputs.labels }}
49+
# Update Docker Hub from README
50+
- name: Docker Hub Description
51+
uses: peter-evans/dockerhub-description@v3
52+
with:
53+
username: ${{ secrets.DOCKER_HUB_USERNAME }}
54+
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
55+
repository: ${{ env.IMAGE_NAME }}
56+
readme-filepath: ./README.md
57+
short-description: "Metronome API layer for Kubernetes"
58+
59+
github-release:
60+
runs-on: ubuntu-latest
61+
needs: [build-and-push-image]
62+
steps:
63+
- run: "echo \"RELEASE_TAG=${GITHUB_REF#refs/tags/}\" >> $GITHUB_ENV"
64+
- uses: actions/github-script@v5
65+
if: startsWith(github.ref, 'refs/tags/')
66+
with:
67+
github-token: ${{ secrets.GITHUB_TOKEN }}
68+
script: |
69+
try {
70+
await github.rest.repos.createRelease({
71+
draft: false,
72+
generate_release_notes: true,
73+
name: process.env.RELEASE_TAG,
74+
owner: context.repo.owner,
75+
prerelease: false,
76+
repo: context.repo.repo,
77+
tag_name: process.env.RELEASE_TAG,
78+
});
79+
} catch (error) {
80+
core.setFailed(error.message);
81+
}

0 commit comments

Comments
 (0)