@@ -2,15 +2,13 @@ name: Build and Push Image
22
33on :
44 push :
5- branches :
6- - ' main'
7- - ' dev'
8- paths :
9- - server/const.py
5+ tags :
6+ - ' v*'
107
118jobs :
129 build-and-push-image :
1310 runs-on : ubuntu-latest
11+
1412 steps :
1513
1614 - name : Checkout repository
@@ -30,38 +28,22 @@ jobs:
3028
3129 - name : Extract repository name
3230 id : repo
33- run : |
34- echo "REPO=$(basename ${{ github.repository }})" >> $GITHUB_ENV
35- echo VERSION=$(grep "VERSION " server/const.py | sed "s/.*VERSION = ['|\"]\(.*\)['|\"].*/\1/") >> $GITHUB_ENV
31+ run : echo "REPO=$(basename ${{ github.repository }})" >> $GITHUB_ENV
3632
3733 - name : Extract metadata (tags, labels) for Docker
3834 id : meta
3935 uses : docker/metadata-action@v5
4036 with :
4137 images : nineaiyu/${{ env.REPO }}
4238 tags : |
43- type=semver,pattern={{version}}, value=${{ env.VERSION }}
39+ type=semver,pattern={{version}}
4440
4541 - name : Build and push multi-arch image
4642 uses : docker/build-push-action@v6
4743 with :
44+ build-args : VERSION=${{ steps.meta.outputs.version }}
4845 platforms : linux/amd64,linux/arm64
4946 push : true
5047 file : Dockerfile
5148 tags : ${{ steps.meta.outputs.tags }}
5249 labels : ${{ steps.meta.outputs.labels }}
53-
54- - name : Update docker-compose.yml
55- run : |
56- sed -i 's@image: nineaiyu/.*@image: nineaiyu/${{ env.REPO }}:${{ env.VERSION }}@' docker-compose.yml
57- sed -i 's@image: nineaiyu/.*@image: nineaiyu/${{ env.REPO }}:${{ env.VERSION }}@' docker-compose-sqlite.yml
58-
59- - name : Commit changes
60- run : |
61- git config --global user.name 'github-actions[bot]'
62- git config --global user.email 'github-actions[bot]@users.noreply.github.com'
63- git add docker-compose.yml docker-compose-sqlite.yml
64- git commit -m "perf: Update docker-compose.yml with new image tag"
65- git push origin ${{ github.event.pull_request.head.ref }}
66- env :
67- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments