Skip to content

Commit c0af7ad

Browse files
committed
Refactor GitHub Actions workflow to build Docker images with enhanced steps for authentication and metadata extraction. Added support for ACR login and improved image tagging strategies.
1 parent a3cba69 commit c0af7ad

File tree

1 file changed

+76
-9
lines changed

1 file changed

+76
-9
lines changed

.github/workflows/build.yaml

Lines changed: 76 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,80 @@ on:
66
- rss3-main
77
tags:
88
- v*
9+
10+
env:
11+
ACR_INSTANCE_ID: cri-0jrfa7tkgiwjzabf
12+
13+
permissions:
14+
contents: read
15+
packages: write
16+
id-token: write
17+
918
jobs:
10-
build:
11-
uses: NaturalSelectionLabs/Daedalus/.github/workflows/docker-tpl.yaml@main
12-
with:
13-
images: rss3/op-geth
14-
context: .
15-
dockerfile: ./Dockerfile
16-
secrets:
17-
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
18-
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
19+
build-images:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v4
24+
- name: Set up QEMU
25+
uses: docker/setup-qemu-action@v3
26+
- name: Set up Docker Buildx
27+
uses: docker/setup-buildx-action@v2
28+
29+
- name: Login to DockerHub
30+
uses: docker/login-action@v3
31+
with:
32+
username: ${{ secrets.DOCKERHUB_USERNAME }}
33+
password: ${{ secrets.DOCKERHUB_TOKEN }}
34+
35+
- name: Login to GitHub Container Registry
36+
uses: docker/login-action@v3
37+
with:
38+
registry: ghcr.io
39+
username: ${{ github.actor }}
40+
password: ${{ github.token }}
41+
42+
- name: setup aliyun cli
43+
uses: aliyun/setup-aliyun-cli-action@v1
44+
45+
- name: get acr credential
46+
id: acr-cred
47+
run: |
48+
RESPONSE=$(aliyun cr GetAuthorizationToken --region us-east-1 --InstanceId ${{ env.ACR_INSTANCE_ID }})
49+
TEMP_USERNAME=$(echo "$RESPONSE" | jq -r '.TempUsername')
50+
AUTH_TOKEN=$(echo "$RESPONSE" | jq -r '.AuthorizationToken')
51+
52+
echo "::add-mask::$AUTH_TOKEN"
53+
54+
echo "username=$TEMP_USERNAME" >> $GITHUB_OUTPUT
55+
echo "password=$AUTH_TOKEN" >> $GITHUB_OUTPUT
56+
57+
- name: Login to ACR
58+
uses: docker/login-action@v3
59+
with:
60+
registry: container-registry.us-east-1.cr.aliyuncs.com
61+
username: ${{ steps.acr-cred.outputs.username }}
62+
password: ${{ steps.acr-cred.outputs.password }}
63+
64+
- name: Extract metadata (tags, labels) for Docker
65+
id: meta
66+
uses: docker/metadata-action@v4
67+
with:
68+
images: |
69+
rss3/op-geth
70+
${{ github.repository }}
71+
container-registry.us-east-1.cr.aliyuncs.com/rss3/op-geth
72+
tags: |
73+
type=raw,value=latest,enable={{is_default_branch}}
74+
type=semver,pattern={{version}}
75+
type=semver,pattern={{major}}.{{minor}}
76+
type=semver,pattern={{major}}
77+
type=semver,pattern=v{{version}}
78+
type=semver,pattern=v{{major}}.{{minor}}
79+
type=semver,pattern=v{{major}}
80+
type=ref,event=branch
81+
type=ref,event=pr
82+
type=sha
83+
type=sha,format=long
84+
type=sha,prefix={{branch}}-,enable=${{ !startsWith(github.ref, 'refs/tags') }},event=branch
85+
type=sha,format=long,prefix={{branch}}-,enable=${{ !startsWith(github.ref, 'refs/tags') }},event=branch

0 commit comments

Comments
 (0)