-
Notifications
You must be signed in to change notification settings - Fork 190
125 lines (112 loc) · 4.97 KB
/
Copy pathpush_db_image.yml
File metadata and controls
125 lines (112 loc) · 4.97 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# ThingsPanel 基础镜像同步工作流
#
# 功能说明:
# 将 TimescaleDB 和 Redis 的公共镜像同步到 GitHub Container Registry (GHCR)
# 和阿里云容器镜像服务,并保留 multi-arch manifest。
# 便于用户从 GHCR 统一拉取所需的基础镜像
#
# 触发方式:
# - 手动触发: 通过 GitHub Actions 页面手动触发同步
#
# 镜像同步列表:
# 1. TimescaleDB:
# - 源镜像: timescale/timescaledb:2.8.1-pg14
# - 目标: ghcr.io/<owner>/timescaledb:2.8.1-pg14
#
# 2. Redis:
# - 源镜像: redis:6.2.7
# - 目标: ghcr.io/<owner>/redis:6.2.7
#
# 执行步骤:
# 1. 检出代码
# 2. 设置 Docker Buildx
# 3. 登录 GitHub Container Registry
# 4. 转换仓库所有者为小写(GHCR要求)
# 5. 拉取并推送 TimescaleDB 镜像
# 6. 拉取并推送 Redis 镜像
#
# 必需的 Secrets:
# - GITHUB_TOKEN: GitHub 自动提供的访问令牌
# - IMAGE_USER: 阿里云容器镜像服务用户名
# - IMAGE_PASS: 阿里云容器镜像服务密码
#
# 注意事项:
# 1. 确保 GITHUB_TOKEN 有写入包的权限
# 2. 确保 GHCR 仓库已正确配置访问权限
# 3. 镜像版本更新时需要同步修改工作流文件
# 4. 建议定期执行以确保镜像可用性
name: Publish Docker Images to GitHub
on:
workflow_dispatch:
jobs:
push_to_registry:
name: Push Docker images to GitHub Container Registry
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Log in to Aliyun Container Registry
uses: docker/login-action@v3
with:
registry: registry.cn-hangzhou.aliyuncs.com
username: ${{ secrets.IMAGE_USER }}
password: ${{ secrets.IMAGE_PASS }}
- name: Set lowercase owner name
run: |
echo "OWNER_LC=${GITHUB_REPOSITORY_OWNER,,}" >>${GITHUB_ENV}
- name: Install skopeo
run: |
sudo apt-get update
sudo apt-get install -y skopeo
- name: Copy TimescaleDB multi-arch image
run: |
skopeo copy --override-os linux --override-arch amd64 \
docker://docker.io/timescale/timescaledb:2.8.1-pg14 \
docker://ghcr.io/${{ env.OWNER_LC }}/timescaledb:2.8.1-pg14-amd64
skopeo copy --override-os linux --override-arch arm64 \
docker://docker.io/timescale/timescaledb:2.8.1-pg14 \
docker://ghcr.io/${{ env.OWNER_LC }}/timescaledb:2.8.1-pg14-arm64
docker buildx imagetools create \
-t ghcr.io/${{ env.OWNER_LC }}/timescaledb:2.8.1-pg14 \
ghcr.io/${{ env.OWNER_LC }}/timescaledb:2.8.1-pg14-amd64 \
ghcr.io/${{ env.OWNER_LC }}/timescaledb:2.8.1-pg14-arm64
skopeo copy --override-os linux --override-arch amd64 \
docker://docker.io/timescale/timescaledb:2.8.1-pg14 \
docker://registry.cn-hangzhou.aliyuncs.com/thingspanel/timescaledb:14-amd64
skopeo copy --override-os linux --override-arch arm64 \
docker://docker.io/timescale/timescaledb:2.8.1-pg14 \
docker://registry.cn-hangzhou.aliyuncs.com/thingspanel/timescaledb:14-arm64
docker buildx imagetools create \
-t registry.cn-hangzhou.aliyuncs.com/thingspanel/timescaledb:14 \
registry.cn-hangzhou.aliyuncs.com/thingspanel/timescaledb:14-amd64 \
registry.cn-hangzhou.aliyuncs.com/thingspanel/timescaledb:14-arm64
- name: Copy Redis multi-arch image
run: |
skopeo copy --override-os linux --override-arch amd64 \
docker://docker.io/library/redis:6.2.7 \
docker://ghcr.io/${{ env.OWNER_LC }}/redis:6.2.7-amd64
skopeo copy --override-os linux --override-arch arm64 \
docker://docker.io/library/redis:6.2.7 \
docker://ghcr.io/${{ env.OWNER_LC }}/redis:6.2.7-arm64
docker buildx imagetools create \
-t ghcr.io/${{ env.OWNER_LC }}/redis:6.2.7 \
ghcr.io/${{ env.OWNER_LC }}/redis:6.2.7-amd64 \
ghcr.io/${{ env.OWNER_LC }}/redis:6.2.7-arm64
skopeo copy --override-os linux --override-arch amd64 \
docker://docker.io/library/redis:6.2.7 \
docker://registry.cn-hangzhou.aliyuncs.com/thingspanel/redis:6.2.7-amd64
skopeo copy --override-os linux --override-arch arm64 \
docker://docker.io/library/redis:6.2.7 \
docker://registry.cn-hangzhou.aliyuncs.com/thingspanel/redis:6.2.7-arm64
docker buildx imagetools create \
-t registry.cn-hangzhou.aliyuncs.com/thingspanel/redis:6.2.7 \
registry.cn-hangzhou.aliyuncs.com/thingspanel/redis:6.2.7-amd64 \
registry.cn-hangzhou.aliyuncs.com/thingspanel/redis:6.2.7-arm64