chore: add Aliyun credentials configuration and enhance Docker login … #135
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 | |
| - 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: | |
| login-server: https://container-registry.us-east-1.cr.aliyuncs.com | |
| region-id: "us-east-1" | |
| instance-id: cri-0jrfa7tkgiwjzabf | |
| - 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) }} | |
| include: | |
| - registry: ghcr.io | |
| repository: ${{ github.repository }} | |
| - registry: docker.io | |
| repository: rss3 | |
| - registry: container-registry.us-east-1.cr.aliyuncs.com | |
| 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: | |
| login-server: https://container-registry.us-east-1.cr.aliyuncs.com | |
| region-id: "us-east-1" | |
| 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 }} |