-
Notifications
You must be signed in to change notification settings - Fork 0
58 lines (44 loc) · 1.28 KB
/
push_container_image.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
name: push container image
on:
push:
branches:
- "main"
tags:
- "v*"
workflow_dispatch: {}
jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- uses: ko-build/[email protected]
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
- run: ko publish --bare --tags "${{ steps.meta.outputs.tags }},latest" ./cmd/prel
- name: Update Release Body
# when ref is a tag, github.ref is like refs/tags/v1.0.0
if: startsWith(github.ref, 'refs/tags/')
run: |
RELEASE_ID="${{ github.ref }}"
RELEASE_ID="${RELEASE_ID#refs/tags/}"
IMAGE="ghcr.io/lirlia/prel:${RELEASE_ID}"
gh release view ${RELEASE_ID} --json body -q '.body' > note.md
cat << EOF > note.md
$(cat note.md)
## Container Image
\`\`\`bash
docker pull ${IMAGE}
\`\`\`
EOF
gh release edit "$RELEASE_ID" --notes-file note.md
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}