Build and Push Docker Image #278
This file contains 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 and Push Docker Image | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- 'main' | |
tags: | |
- 'v*' | |
paths: | |
- '.github/actions/build-and-push-docker/action.yml' | |
- '.github/workflows/docker.yml' | |
- 'docker-bake.hcl' | |
- 'cann/**' | |
- 'pytorch/**' | |
- 'mindspore/**' | |
- '!**/*.md' | |
pull_request: | |
branches: | |
- 'main' | |
paths: | |
- '.github/actions/build-and-push-docker/action.yml' | |
- '.github/workflows/docker.yml' | |
- 'docker-bake.hcl' | |
- 'cann/**' | |
- 'pytorch/**' | |
- 'mindspore/**' | |
- '!**/*.md' | |
release: | |
types: | |
- 'published' | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: ${{ !contains(github.ref, 'release/')}} | |
env: | |
registries: | | |
[ | |
{ | |
"url": "docker.io", | |
"owner": "${{ secrets.DOCKERHUB_OWNER }}" | |
}, | |
{ | |
"url": "ghcr.io", | |
"owner": "${{ github.repository_owner }}" | |
}, | |
{ | |
"url": "quay.io", | |
"owner": "${{ secrets.QUAY_OWNER }}" | |
} | |
] | |
jobs: | |
prepare: | |
name: prepare | |
runs-on: ubuntu-latest | |
outputs: | |
cann-targets: ${{ steps.list-cann-target.outputs.targets }} | |
pth-targets: ${{ steps.list-pth-target.outputs.targets }} | |
ms-targets: ${{ steps.list-ms-target.outputs.targets }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: List cann targets | |
id: list-cann-target | |
uses: docker/bake-action/subaction/list-targets@v4 | |
with: | |
target: cann | |
- name: List pytorch targets | |
id: list-pth-target | |
uses: docker/bake-action/subaction/list-targets@v4 | |
with: | |
target: pytorch | |
- name: List mindspore targets | |
id: list-ms-target | |
uses: docker/bake-action/subaction/list-targets@v4 | |
with: | |
target: mindspore | |
cann: | |
name: cann | |
runs-on: ubuntu-latest | |
permissions: | |
packages: write | |
needs: | |
- prepare | |
strategy: | |
fail-fast: false | |
matrix: | |
target: ${{ fromJson(needs.prepare.outputs.cann-targets) }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Build and push Docker | |
uses: ./.github/actions/build-and-push-docker | |
with: | |
target: ${{ matrix.target }} | |
dockerhub_owner: ${{ secrets.DOCKERHUB_OWNER }} | |
dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }} | |
dockerhub_token: ${{ secrets.DOCKERHUB_TOKEN }} | |
quay_owner: ${{ secrets.QUAY_OWNER }} | |
quay_username: ${{ secrets.QUAY_USERNAME }} | |
quay_token: ${{ secrets.QUAY_TOKEN }} | |
pytorch: | |
name: pytorch | |
runs-on: ubuntu-latest | |
if: ${{ success() || failure() }} | |
permissions: | |
packages: write | |
needs: | |
- prepare | |
- cann | |
strategy: | |
fail-fast: false | |
matrix: | |
target: ${{ fromJson(needs.prepare.outputs.pth-targets) }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Build and push Docker | |
uses: ./.github/actions/build-and-push-docker | |
with: | |
target: ${{ matrix.target }} | |
dockerhub_owner: ${{ secrets.DOCKERHUB_OWNER }} | |
dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }} | |
dockerhub_token: ${{ secrets.DOCKERHUB_TOKEN }} | |
quay_owner: ${{ secrets.QUAY_OWNER }} | |
quay_username: ${{ secrets.QUAY_USERNAME }} | |
quay_token: ${{ secrets.QUAY_TOKEN }} | |
mindspore: | |
name: mindspore | |
runs-on: ubuntu-latest | |
if: ${{ success() || failure() }} | |
permissions: | |
packages: write | |
needs: | |
- prepare | |
- cann | |
strategy: | |
fail-fast: false | |
matrix: | |
target: ${{ fromJson(needs.prepare.outputs.ms-targets) }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Build and push Docker | |
uses: ./.github/actions/build-and-push-docker | |
with: | |
target: ${{ matrix.target }} | |
dockerhub_owner: ${{ secrets.DOCKERHUB_OWNER }} | |
dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }} | |
dockerhub_token: ${{ secrets.DOCKERHUB_TOKEN }} | |
quay_owner: ${{ secrets.QUAY_OWNER }} | |
quay_username: ${{ secrets.QUAY_USERNAME }} | |
quay_token: ${{ secrets.QUAY_TOKEN }} |