@@ -11,33 +11,52 @@ jobs:
1111 runs-on : ubuntu-latest
1212
1313 steps :
14- - name : 拉取源码
14+ - name : Pull The Codes
1515 uses : actions/checkout@v3
1616 with :
17- fetch-depth : 1
17+ fetch-depth : 0 # Must be 0 so we can fetch tags
1818
19- - name : 设置 QEMU
19+ - name : Get latest tag (only on manual trigger)
20+ id : get-latest-tag
21+ if : github.event_name == 'workflow_dispatch'
22+ run : |
23+ tag=$(git describe --tags --abbrev=0)
24+ echo "latest_tag=$tag" >> $GITHUB_OUTPUT
25+
26+ - name : Checkout to latest tag (only on manual trigger)
27+ if : github.event_name == 'workflow_dispatch'
28+ run : git checkout ${{ steps.get-latest-tag.outputs.latest_tag }}
29+
30+ - name : Set QEMU
2031 uses : docker/setup-qemu-action@v3
2132
22- - name : 设置 Docker Buildx
33+ - name : Set Docker Buildx
2334 uses : docker/setup-buildx-action@v3
2435
25- - name : 登录到 DockerHub
36+ - name : Log in to DockerHub
2637 uses : docker/login-action@v3
2738 with :
2839 username : ${{ secrets.DOCKER_HUB_USERNAME }}
2940 password : ${{ secrets.DOCKER_HUB_PASSWORD }}
3041
31- - name : 构建和推送 Docker hub
42+ - name : Login to GitHub Container Registry
43+ uses : docker/login-action@v3
44+ with :
45+ registry : ghcr.io
46+ username : Soulter
47+ password : ${{ secrets.GITHUB_TOKEN }}
48+
49+ - name : Build and Push Docker to DockerHub and Github GHCR
3250 uses : docker/build-push-action@v6
3351 with :
3452 context : .
3553 platforms : linux/amd64,linux/arm64
3654 push : true
3755 tags : |
3856 ${{ secrets.DOCKER_HUB_USERNAME }}/astrbot:latest
39- ${{ secrets.DOCKER_HUB_USERNAME }}/astrbot:${{ github.ref_name }}
57+ ${{ secrets.DOCKER_HUB_USERNAME }}/astrbot:${{ github.event_name == 'workflow_dispatch' && steps.get-latest-tag.outputs.latest_tag || github.ref_name }}
58+ ghcr.io/soulter/astrbot:latest
59+ ghcr.io/soulter/astrbot:${{ github.event_name == 'workflow_dispatch' && steps.get-latest-tag.outputs.latest_tag || github.ref_name }}
4060
4161 - name : Post build notifications
4262 run : echo "Docker image has been built and pushed successfully"
43-
0 commit comments