-
Notifications
You must be signed in to change notification settings - Fork 0
114 lines (99 loc) · 3.76 KB
/
docker-image.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
name: Build nuwas Docker Image
on:
push:
branches:
- main
env:
REGISTRY: ghcr.io
IMAGE_NAME: bitrainforest/pulsar
BONY_CALIBNET_TARGET: calibnet
BONY_MAINNET_TARGET: mainnet
jobs:
build-push-docker:
runs-on: ubuntu-latest
env:
TZ: Asia/Shanghai
REGISTRY: ghcr.io
steps:
- name: Checkout
uses: actions/checkout@v2
# 配置 QEMU 和 buildx 用于多架构镜像的构建
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Inspect builder
run: |
echo "Name: ${{ steps.buildx.outputs.name }}"
echo "Endpoint: ${{ steps.buildx.outputs.endpoint }}"
echo "Status: ${{ steps.buildx.outputs.status }}"
echo "Flags: ${{ steps.buildx.outputs.flags }}"
echo "Platforms: ${{ steps.buildx.outputs.platforms }}"
# 登录到 GitHub Packages 容器仓库
# 注意 secrets.GITHUB_TOKEN 不需要手动添加,直接就可以用
- name: Log in to the Container registry
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata for Docker (${{ env.BONY_MAINNET_TARGET }})
id: meta-for-mainnet
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
flavor: |
latest=false
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=ref,event=branch
type=ref,event=pr
- name: Build and push Docker image (${{ env.BONY_MAINNET_TARGET }})
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: ${{ steps.meta-for-mainnet.outputs.tags }}
labels: ${{ steps.meta-for-mainnet.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
BONY_NETWORK_TARGET=${{ env.BONY_MAINNET_TARGET }}
GO_BUILD_IMAGE=${{ env.GO_BUILD_IMAGE }}
# 根据输入自动生成 tag 和 label 等数据
- name: Extract metadata for Docker (${{ env.BONY_CALIBNET_TARGET }})
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
flavor: |
latest=false
tags: |
type=semver,pattern={{version}},suffix=-${{ env.BONY_CALIBNET_TARGET }}
type=semver,pattern={{major}}.{{minor}},suffix=-${{ env.BONY_CALIBNET_TARGET }}
type=semver,pattern={{major}}.{{minor}},suffix=-${{ env.BONY_CALIBNET_TARGET }}
type=semver,pattern={{major}},suffix=-${{ env.BONY_CALIBNET_TARGET }}
type=ref,event=branch,suffix=-${{ env.BONY_CALIBNET_TARGET }}
type=ref,event=pr,suffix=-${{ env.BONY_CALIBNET_TARGET }}
type=semver,pattern={{version}},suffix=-${{ env.BONY_CALIBNET_TARGET }}
type=raw,value=main-latest
# 构建并上传
- name: Build and push (${{ env.BONY_CALIBNET_TARGET }})
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
#
# deploy:
# needs: [ build-push-docker ]
# runs-on: self-hosted
# steps:
# - name: CD - Deploy
# run: ansible deploy -m shell -a 'bash /root/shell/backend/deploy-nuwas.sh'