GitHub Actions 构建镜像且同步到阿里云单个 ACR

GitHub Actions 构建镜像且同步到阿里云单个 ACR

.github/workflows/acr.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
name: Acr

on:
push:
branches:
- main

env:
NAME: hongfs/tools # 仓库名称
REGION: cn-shenzhen # 仓库地域

jobs:
Build:
runs-on: ubuntu-22.04
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
steps:
- uses: actions/checkout@v3
- name: Run
run: |
cd $GITHUB_WORKSPACE
echo "---这里你要替换成登录操作---"

docker build --no-cache -t $GITHUB_REPOSITORY:$GITHUB_REF_NAME .

docker tag $GITHUB_REPOSITORY:$GITHUB_REF_NAME "registry.$region.aliyuncs.com/$NAME:$GITHUB_REF_NAME"
docker push "registry.$region.aliyuncs.com/$NAME:$GITHUB_REF_NAME"
往上