|
4 | 4 | name: CI |
5 | 5 |
|
6 | 6 | on: |
| 7 | + push: |
| 8 | + branches: [ "main" ] |
| 9 | + tags: |
| 10 | + - v[0-9]+.[0-9]+.[0-9]+.[0-9]+ |
| 11 | + - v[0-9]+.[0-9]+.[0-9]+ |
| 12 | + - v[0-9]+.[0-9]+ |
7 | 13 | pull_request: |
8 | 14 | branches: [ "main" ] |
9 | 15 |
|
@@ -60,20 +66,38 @@ jobs: |
60 | 66 | name: build-artifacts |
61 | 67 | path: ./lib/hami-vnpu-core/ |
62 | 68 |
|
| 69 | + - name: Docker Login |
| 70 | + if: ${{ github.event_name == 'push' && (startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main') }} |
| 71 | + uses: docker/login-action@v3.6.0 |
| 72 | + with: |
| 73 | + username: ${{ secrets.DOCKERHUB_TOKEN }} |
| 74 | + password: ${{ secrets.DOCKERHUB_PASSWD }} |
| 75 | + |
63 | 76 | - name: Set up QEMU |
64 | 77 | uses: docker/setup-qemu-action@v3 |
65 | 78 |
|
66 | 79 | - name: Set up Docker Buildx |
67 | 80 | uses: docker/setup-buildx-action@v3 |
68 | 81 |
|
| 82 | + - name: Extract tag name |
| 83 | + id: tag |
| 84 | + run: | |
| 85 | + if [[ "${{ github.ref }}" == refs/tags/* ]]; then |
| 86 | + TAG_NAME="${GITHUB_REF#refs/tags/}" |
| 87 | + echo "VERSION=${TAG_NAME#v}" >> $GITHUB_OUTPUT |
| 88 | + echo "Extracted version: ${VERSION}" |
| 89 | + else |
| 90 | + echo "VERSION=latest" >> $GITHUB_OUTPUT |
| 91 | + fi |
| 92 | +
|
69 | 93 | - name: Build and push |
70 | 94 | uses: docker/build-push-action@v6 |
71 | 95 | with: |
72 | 96 | context: . |
73 | | - platforms: linux/amd64 |
74 | | - push: false |
| 97 | + platforms: linux/amd64,linux/arm64 |
| 98 | + push: ${{ github.event_name == 'push' && (startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main') }} |
75 | 99 | build-args: | |
76 | 100 | BASE_IMAGE=ubuntu:20.04 |
77 | 101 | GO_VERSION=${{ env.GO_VERSION }} |
78 | 102 | VERSION=${{ steps.branch-names.outputs.current_branch || steps.branch-names.outputs.tag }}-${{ github.sha }} |
79 | | - tags: ${{ env.IMAGE_NAME }}:dev |
| 103 | + tags: ${{ env.IMAGE_NAME }}:${{ steps.tag.outputs.VERSION }} |
0 commit comments