-
Notifications
You must be signed in to change notification settings - Fork 0
51 lines (40 loc) · 1.73 KB
/
update-docker-manifest.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
name: update-docker-manifest
on:
schedule:
- cron: 0 19 * * * # run at 4 AM JST
workflow_dispatch:
jobs:
update-docker-manifest:
runs-on: ubuntu-latest
env:
PACKAGE_NAME: autoware-universe
steps:
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ github.token }}
- name: Create Docker manifest
run: |
package_full_name=ghcr.io/${{ github.repository_owner }}/${{ env.PACKAGE_NAME }}
url="https://api.github.com/orgs/${{ github.repository_owner }}/packages/container/${{ env.PACKAGE_NAME }}/versions"
echo "url: $url"
tags=$(curl -fsSL "$url" -H "Authorization: token ${{ github.token }}" | jq ".[].metadata.container.tags[]" | cut -d '"' -f 2)
amd64_tags=$(echo "$tags" | grep "\-amd64" | sed "s/-amd64$//g")
arm64_tags=$(echo "$tags" | grep "\-arm64" | sed "s/-arm64$//g")
base_tags=$(printf "%s\n" "$amd64_tags" "$arm64_tags" | sort | uniq)
echo "amd64_tags: "$amd64_tags""
echo "arm64_tags: "$arm64_tags""
echo "base_tags: "$base_tags""
for base_tag in $base_tags; do
amd64_tag="$package_full_name":$(echo "$tags" | grep "$base_tag\-amd64")
arm64_tag="$package_full_name":$(echo "$tags" | grep "$base_tag\-arm64")
echo "base_tag: $base_tag"
echo "amd64_tag: $amd64_tag"
echo "arm64_tag: $arm64_tag"
docker manifest create $package_full_name:$base_tag \
$amd64_tag \
$arm64_tag
docker manifest push $package_full_name:$base_tag
done