-
Notifications
You must be signed in to change notification settings - Fork 0
101 lines (89 loc) · 3.18 KB
/
Copy pathdocker.yml
File metadata and controls
101 lines (89 loc) · 3.18 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
name: Build and Publish Docker Image
on:
workflow_dispatch:
env:
GHCR_IMAGE: ghcr.io/hackycy/hackycy-cli
TENCENT_IMAGE: sgccr.ccs.tencentyun.com/sooosin-sg/hackycy-cli
PLATFORMS: linux/amd64,linux/arm64
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Verify selected ref is a release tag
if: github.ref_type != 'tag'
run: |
echo 'Run this workflow from a release tag, for example v0.0.x.' >&2
exit 1
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
- name: Download Linux binaries from GitHub Release
env:
GH_TOKEN: ${{ github.token }}
RELEASE_TAG: ${{ github.ref_name }}
run: |
mkdir -p release-assets docker-artifacts/ycy-linux-x64 docker-artifacts/ycy-linux-arm64
gh release download "$RELEASE_TAG" \
--repo "$GITHUB_REPOSITORY" \
--pattern ycy-linux-x64 \
--pattern ycy-linux-arm64 \
--pattern SHA256SUMS \
--dir release-assets
cd release-assets
grep -E ' (ycy-linux-x64|ycy-linux-arm64)$' SHA256SUMS | sha256sum -c -
cd ..
mv release-assets/ycy-linux-x64 docker-artifacts/ycy-linux-x64/ycy-linux-x64
mv release-assets/ycy-linux-arm64 docker-artifacts/ycy-linux-arm64/ycy-linux-arm64
chmod +x docker-artifacts/ycy-linux-*/ycy-linux-*
- name: Resolve image tags
id: image
env:
TAG: ${{ github.ref_name }}
GHCR_IMAGE: ${{ env.GHCR_IMAGE }}
TENCENT_IMAGE: ${{ env.TENCENT_IMAGE }}
run: |
{
echo 'tags<<EOF'
echo "$GHCR_IMAGE:$TAG"
echo "$TENCENT_IMAGE:$TAG"
echo "$GHCR_IMAGE:latest"
echo "$TENCENT_IMAGE:latest"
echo 'EOF'
} >> "$GITHUB_OUTPUT"
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Log in to Tencent Cloud Container Registry
uses: docker/login-action@v3
with:
registry: sgccr.ccs.tencentyun.com
username: ${{ secrets.TENCENT_USERNAME }}
password: ${{ secrets.TENCENT_PASSWORD }}
- name: Build and publish image
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile
platforms: ${{ env.PLATFORMS }}
push: true
tags: ${{ steps.image.outputs.tags }}
labels: |
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
org.opencontainers.image.revision=${{ github.sha }}
cache-from: |
type=gha,scope=ghcr-hackycy-cli
type=gha,scope=tencent-hackycy-cli
cache-to: |
type=gha,mode=max,scope=ghcr-hackycy-cli
type=gha,mode=max,scope=tencent-hackycy-cli