-
Notifications
You must be signed in to change notification settings - Fork 0
169 lines (144 loc) · 4.91 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
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
name: Publish Docker
on:
workflow_call:
inputs:
tag:
required: true
type: string
description: 'Tag to build'
dry-run:
type: boolean
default: false
description: 'Action is a dry run'
secrets:
DOCKERHUB_TOKEN:
required: true
description: 'DockerHub token'
GITHUB_TOKEN:
required: true
description: 'GitHub token'
jobs:
meta:
name: Fetch metadata
runs-on: ubuntu-20.04
outputs:
link_x86_64: ${{ steps.release.outputs.link_x86_64 }}
link_aarch64: ${{ steps.release.outputs.link_aarch64 }}
version: ${{ steps.release.outputs.version }}
valid: ${{ steps.check-tag.outputs.valid }}
steps:
- name: Find release
id: release
run: |
JSON=$(curl -s https://caido.download/releases/latest)
LINK_x86_64=$(jq -r '.links[] | select(.platform == "linux-x86_64" and .kind == "cli") | .link' <<< $JSON)
echo "link_x86_64=$LINK_x86_64" >> $GITHUB_OUTPUT
LINK_AARCH64=$(jq -r '.links[] | select(.platform == "linux-aarch64" and .kind == "cli") | .link' <<< $JSON)
echo "link_aarch64=$LINK_AARCH64" >> $GITHUB_OUTPUT
VERSION=$(jq -r '.version' <<< $JSON)
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Check Tag
id: check-tag
run: |
if [[ v${{ steps.release.outputs.version }} == ${{ inputs.tag }} ]]; then
echo "valid=true" >> $GITHUB_OUTPUT
fi
publish:
name: Publish images
runs-on: ubuntu-latest
if: ${{ needs.meta.outputs.valid == 'true' }}
needs: meta
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Fetch x86_64 binary
run: |
mkdir -p docker/x86_64
curl -L ${{ needs.meta.outputs.link_x86_64 }} --output caido.tar.gz
tar -xf caido.tar.gz
mv caido-cli docker/x86_64/
rm caido.tar.gz
- name: Fetch aarch64 binary
run: |
mkdir -p docker/aarch64
curl -L ${{ needs.meta.outputs.link_aarch64 }} --output caido.tar.gz
tar -xf caido.tar.gz
mv caido-cli docker/aarch64/
rm caido.tar.gz
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: caidobot
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: caido
password: ${{ secrets.GITHUB_TOKEN }}
- name: Generate Docker metadata (slim)
id: meta-slim
uses: docker/metadata-action@v5
with:
images: |
caido/caido
ghcr.io/caido/caido
tags: |
type=raw,value=latest-slim
type=raw,value=${{ inputs.version }}-slim
type=semver,pattern={{version}}-slim,value=${{ inputs.version }}
- name: Generate Docker metadata (full)
id: meta-full
uses: docker/metadata-action@v5
with:
images: |
caido/caido
ghcr.io/caido/caido
tags: |
type=raw,value=latest
type=raw,value=${{ inputs.version }}
type=semver,pattern={{version}},value=${{ inputs.version }}
- name: Build and push x86_64 (slim)
if: inputs.dry-run == false
uses: docker/build-push-action@v5
with:
context: docker/x86_64
platforms: linux/amd64
push: true
tags: ${{ steps.meta-slim.outputs.tags }}
labels: ${{ steps.meta-slim.outputs.labels }}
file: docker/Dockerfile.slim
- name: Build and push x86_64 (full)
if: inputs.dry-run == false
uses: docker/build-push-action@v5
with:
context: docker/x86_64
platforms: linux/amd64
push: true
tags: ${{ steps.meta-full.outputs.tags }}
labels: ${{ steps.meta-full.outputs.labels }}
file: docker/Dockerfile.full
- name: Build and push aarch64 (slim)
if: inputs.dry-run == false
uses: docker/build-push-action@v5
with:
context: docker/aarch64
platforms: linux/arm64
push: true
tags: ${{ steps.meta-slim.outputs.tags }}
labels: ${{ steps.meta-slim.outputs.labels }}
file: docker/Dockerfile.slim
- name: Build and push aarch64 (full)
if: inputs.dry-run == false
uses: docker/build-push-action@v5
with:
context: docker/aarch64
platforms: linux/arm64
push: true
tags: ${{ steps.meta-full.outputs.tags }}
labels: ${{ steps.meta-full.outputs.labels }}
file: docker/Dockerfile.full