update workflow #2055
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: workflow | |
| on: | |
| push: | |
| tags: | |
| - '*.*.*' | |
| branches: | |
| - '**' | |
| merge_group: | |
| pull_request: | |
| branches: | |
| - main | |
| jobs: | |
| build-ng: | |
| runs-on: ubuntu-latest | |
| env: | |
| TZ: Europe/Amsterdam | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: actions/setup-node@v6 | |
| with: | |
| node-version: 24 | |
| - run: npm ci --ignore-scripts --legacy-peer-deps | |
| - run: npm run test | |
| build-rs: | |
| runs-on: ubuntu-latest | |
| env: | |
| TZ: Europe/Amsterdam | |
| defaults: | |
| run: | |
| working-directory: ./api | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - run: cargo build --verbose | |
| - run: cargo test --verbose | |
| - run: cargo clippy --verbose -- -D warnings | |
| build-docker: | |
| if: github.event_name != 'pull_request' | |
| needs: [build-rs, build-ng] | |
| strategy: | |
| matrix: | |
| include: | |
| # AMD64 native | |
| - os: ubuntu-latest | |
| arch: amd64 | |
| platforms: linux/amd64 | |
| # ARM64 native | |
| - os: ubuntu-latest | |
| arch: arm64 | |
| platforms: linux/arm64 | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - run: | | |
| REF_NAME="${{ github.ref_name }}" | |
| REF_NAME_LOWER=$(echo "$REF_NAME" | tr '[:upper:]' '[:lower:]') | |
| REF_NAME_CLEAN=$(echo "$REF_NAME_LOWER" | tr -cd '[:alnum:]._-') | |
| REF_NAME_CLEAN=$(echo "$REF_NAME_CLEAN" | sed 's/^[^a-z0-9]*//;s/[^a-z0-9]*$//') | |
| if [[ ! "$REF_NAME_CLEAN" =~ ^[a-z0-9] ]]; then | |
| REF_NAME_CLEAN="0$REF_NAME_CLEAN" | |
| fi | |
| echo "CLEANED_REF_NAME=$REF_NAME_CLEAN" >> $GITHUB_ENV | |
| - name: Set up QEMU | |
| if: matrix.arch == 'arm64' | |
| uses: docker/setup-qemu-action@v3 | |
| - uses: docker/setup-buildx-action@v3 | |
| - uses: docker/login-action@v3 | |
| with: | |
| registry: docker.io | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - uses: peter-evans/dockerhub-description@v5 | |
| if: github.ref == 'refs/heads/main' | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| repository: ${{ github.repository }} | |
| short-description: ${{ github.event.repository.description }} | |
| - uses: docker/build-push-action@v6 | |
| if: startsWith(github.ref, 'refs/tags/') | |
| with: | |
| context: . | |
| push: true | |
| platforms: ${{ matrix.platforms }} | |
| tags: ${{ github.repository }}:latest,${{ github.repository }}:${{ github.ref_name }} | |
| build-args: VERSION_ARG=v${{ github.ref_name }} | |
| cache-from: type=registry,ref=${{ github.repository }}:cache | |
| cache-to: type=registry,ref=${{ github.repository }}:cache,mode=max | |
| - uses: docker/build-push-action@v6 | |
| if: startsWith(github.ref, 'refs/heads/') | |
| with: | |
| context: . | |
| push: true | |
| platforms: ${{ matrix.platforms }} | |
| tags: ${{ github.repository }}:${{ env.CLEANED_REF_NAME }} | |
| build-args: VERSION_ARG=${{ github.sha }}@${{ env.CLEANED_REF_NAME }} | |
| cache-from: type=registry,ref=${{ github.repository }}:cache | |
| cache-to: type=registry,ref=${{ github.repository }}:cache,mode=max | |
| docker-manifest: | |
| if: github.event_name != 'pull_request' | |
| needs: build-docker | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Create multi-arch manifest for tags | |
| if: startsWith(github.ref, 'refs/tags/') | |
| run: | | |
| docker buildx imagetools create \ | |
| -t ${{ github.repository }}:latest \ | |
| ${{ github.repository }}:latest | |
| docker buildx imagetools create \ | |
| -t ${{ github.repository }}:${{ github.ref_name }} \ | |
| ${{ github.repository }}:${{ github.ref_name }} | |
| - name: Create multi-arch manifest for branches | |
| if: startsWith(github.ref, 'refs/heads/') | |
| run: | | |
| docker buildx imagetools create \ | |
| -t ${{ github.repository }}:${{ env.CLEANED_REF_NAME }} \ | |
| ${{ github.repository }}:${{ env.CLEANED_REF_NAME }} |