|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "v*" |
| 7 | + pull_request: |
| 8 | + workflow_dispatch: |
| 9 | + |
| 10 | +permissions: |
| 11 | + contents: read |
| 12 | + actions: write |
| 13 | + |
| 14 | +jobs: |
| 15 | + release: |
| 16 | + name: Build and push |
| 17 | + runs-on: blacksmith-2vcpu-ubuntu-2404-arm |
| 18 | + |
| 19 | + steps: |
| 20 | + - name: Checkout |
| 21 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 22 | + |
| 23 | + - name: Set up QEMU |
| 24 | + uses: docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a # v4.0.0 |
| 25 | + |
| 26 | + - name: Set up Docker Buildx |
| 27 | + uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0 |
| 28 | + |
| 29 | + - name: Login to Docker Hub |
| 30 | + uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0 |
| 31 | + if: github.event_name != 'pull_request' |
| 32 | + with: |
| 33 | + username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 34 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 35 | + |
| 36 | + - name: Login to Huawei SWR |
| 37 | + uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0 |
| 38 | + if: github.event_name != 'pull_request' |
| 39 | + with: |
| 40 | + registry: swr.cn-east-3.myhuaweicloud.com |
| 41 | + username: ${{ secrets.HUAWEI_SWR_USERNAME }} |
| 42 | + password: ${{ secrets.HUAWEI_SWR_TOKEN }} |
| 43 | + |
| 44 | + - name: Extract version |
| 45 | + id: version |
| 46 | + run: | |
| 47 | + if [[ "${{ github.event_name }}" == "pull_request" ]]; then |
| 48 | + echo "VERSION=0.0.0" >> "$GITHUB_OUTPUT" |
| 49 | + else |
| 50 | + echo "VERSION=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT" |
| 51 | + fi |
| 52 | +
|
| 53 | + - name: Build |
| 54 | + run: docker buildx bake --set "*.cache-from=type=gha" --set "*.cache-to=type=gha,mode=max" |
| 55 | + env: |
| 56 | + VERSION: ${{ steps.version.outputs.VERSION }} |
| 57 | + |
| 58 | + - name: Push to Docker Hub |
| 59 | + if: github.event_name != 'pull_request' |
| 60 | + run: docker buildx bake --push --set "*.cache-from=type=gha" |
| 61 | + env: |
| 62 | + VERSION: ${{ steps.version.outputs.VERSION }} |
| 63 | + |
| 64 | + - name: Push to Huawei SWR |
| 65 | + if: github.event_name != 'pull_request' |
| 66 | + run: docker buildx bake --push --set "*.cache-from=type=gha" |
| 67 | + env: |
| 68 | + VERSION: ${{ steps.version.outputs.VERSION }} |
| 69 | + REGISTRY: swr.cn-east-3.myhuaweicloud.com |
0 commit comments