chore: enhance GitHub Actions workflow with max parallel jobs and reg… #134
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: Build Docker Image | |
| on: | |
| push: | |
| branches: | |
| - rss3-dev | |
| - rss3-main | |
| env: | |
| GIT_COMMIT: ${{ github.sha }} | |
| jobs: | |
| prepare: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| targets: ${{ steps.generate.outputs.targets }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: List targets | |
| id: generate | |
| uses: docker/bake-action/subaction/list-targets@v5 | |
| with: | |
| target: validate | |
| files: docker-bake.hcl | |
| stack: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| target: | |
| - op-stack-go | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| with: | |
| platforms: all | |
| - name: Login to DockerHub | |
| uses: docker/login-action@v2 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Build and push | |
| uses: docker/bake-action@v5 | |
| with: | |
| push: true | |
| files: docker-bake.hcl | |
| targets: ${{ matrix.target }} | |
| validate: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| id-token: write | |
| needs: | |
| - prepare | |
| - stack | |
| strategy: | |
| fail-fast: false | |
| max-parallel: 3 | |
| matrix: | |
| target: ${{ fromJson(needs.prepare.outputs.targets) }} | |
| registry: | |
| - docker.io | |
| - ghcr.io | |
| - container-registry.us-east-1.cr.aliyuncs.com | |
| repository: | |
| - rss3 | |
| - ${{ github.repository }} | |
| # ghcr.io with github.repository | |
| # docker.io and aliyun with rss3 | |
| exclude: | |
| - registry: docker.io | |
| repository: ${{ github.repository }} | |
| - registry: container-registry.us-east-1.cr.aliyuncs.com | |
| repository: ${{ github.repository }} | |
| - registry: ghcr.io | |
| repository: rss3 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| with: | |
| platforms: all | |
| - uses: aliyun/configure-aliyun-credentials-action@v1 | |
| id: aliyun-auth | |
| with: | |
| role-to-assume: "acs:ram::5621254376179407:role/docker" | |
| oidc-provider-arn: "acs:ram::5621254376179407:oidc-provider/github" | |
| role-session-name: "github-action-session" | |
| role-session-expiration: 1800 | |
| audience: "sts.aliyuncs.com" | |
| - name: Login to DockerHub | |
| uses: docker/login-action@v2 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Login to ghcr | |
| uses: docker/login-action@v2 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ github.token }} | |
| - name: Login to ACR | |
| id: login-acr | |
| uses: aliyun/acr-login@v2.0.1 | |
| with: | |
| region-id: "us-east-1" | |
| access-key-id: ${{ steps.aliyun-auth.outputs.aliyun-access-key-id }} | |
| access-key-secret: ${{ steps.aliyun-auth.outputs.aliyun-access-key-secret }} | |
| security-token: ${{ steps.aliyun-auth.outputs.aliyun-security-token }} | |
| instance-id: cri-0jrfa7tkgiwjzabf | |
| - name: Build and push | |
| uses: docker/bake-action@v5 | |
| with: | |
| targets: ${{ matrix.target }} | |
| push: true | |
| files: docker-bake.hcl | |
| set: | | |
| ${{ matrix.target }}.args.OP_STACK_GO_BUILDER=rss3/op-stack-go:${{ github.sha }} | |
| env: | |
| REGISTRY: ${{ matrix.registry }} | |
| REPOSITORY: ${{ matrix.repository }} |