-
Notifications
You must be signed in to change notification settings - Fork 87
60 lines (51 loc) · 1.64 KB
/
publish-docker.yml
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
59
60
name: Publish to ghcr
on:
workflow_run:
workflows: [Release]
types:
- completed
env:
REGISTRY: ghcr.io
IMAGE_BASE_TAG: ghcr.io/${{ github.repository }}
ARTIFACT_TAG: x86_64-unknown-linux-musl
permissions:
actions: read
contents: read
packages: write
jobs:
containerize:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: 'Checkout'
uses: actions/checkout@v4
- name: Download binary artifact
uses: actions/download-artifact@v4
with:
name: docker-binary-artifact-${{ env.ARTIFACT_TAG }}
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ github.token }}
- name: Download version artifact
uses: actions/download-artifact@v4
with:
name: docker-tag-artifact
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ github.token }}
- name: Retreive version from artifact
run: |
TEMP_VERSION=$(cat cli-version.txt | tr -d ' \r\n' | sed 's/^[^0-9]*//')
test -z $TEMP_VERSION && exit 1
echo "CLI_VERSION=$TEMP_VERSION" >> $GITHUB_ENV
- name: Login to ghcr
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ env.IMAGE_BASE_TAG }}:${{ env.CLI_VERSION }}, ${{ env.IMAGE_BASE_TAG }}:latest