|
| 1 | +name: Docker build |
| 2 | + |
| 3 | +# Controls when the workflow will run |
| 4 | +on: |
| 5 | + release: |
| 6 | + types: |
| 7 | + - published |
| 8 | + pull_request: |
| 9 | + branches: |
| 10 | + - main |
| 11 | + |
| 12 | +jobs: |
| 13 | + build: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + |
| 16 | + steps: |
| 17 | + - name: Checkout |
| 18 | + uses: actions/checkout@v3 |
| 19 | + |
| 20 | + - name: Set up QEMU |
| 21 | + uses: docker/setup-qemu-action@v2 |
| 22 | + |
| 23 | + - name: Set up Docker Buildx |
| 24 | + id: buildx |
| 25 | + uses: docker/setup-buildx-action@v2 |
| 26 | + |
| 27 | + - name: Login to Docker Hub |
| 28 | + uses: docker/login-action@v2 |
| 29 | + with: |
| 30 | + username: ${{ secrets.DOCKER_USER }} |
| 31 | + password: ${{ secrets.DOCKER_TOKEN }} |
| 32 | + |
| 33 | + - name: Login to CNTK Quay |
| 34 | + uses: docker/login-action@v2 |
| 35 | + with: |
| 36 | + registry: quay.io |
| 37 | + username: ${{ secrets.QUAY_CNTK_USERNAME }} |
| 38 | + password: ${{ secrets.QUAY_CNTK_TOKEN }} |
| 39 | + |
| 40 | + - name: Setup variables |
| 41 | + id: variables |
| 42 | + shell: bash |
| 43 | + run: | |
| 44 | + LATEST_ENABLED="true" |
| 45 | + |
| 46 | + RELEASE_TAG=${GITHUB_REF#refs/tags/} |
| 47 | + RELEASE_TAG_ENABLED="false" |
| 48 | + if [[ "${GITHUB_REF}" =~ refs/tags ]] && [[ "${RELEASE_TAG}" != "main" ]]; then |
| 49 | + RELEASE_TAG_ENABLED="true" |
| 50 | + else |
| 51 | + RELEASE_TAG="main" |
| 52 | + fi |
| 53 | + |
| 54 | + echo "Release tag: ${RELEASE_TAG}" |
| 55 | + echo "release-tag=$RELEASE_TAG" >> $GITHUB_OUTPUT |
| 56 | + |
| 57 | + echo "Release tag enabled: $RELEASE_TAG_ENABLED" |
| 58 | + echo "release-tag-enabled=$RELEASE_TAG_ENABLED" >> $GITHUB_OUTPUT |
| 59 | + |
| 60 | + echo "Latest enabled: $LATEST_ENABLED" |
| 61 | + echo "latest-enabled=$LATEST_ENABLED" >> $GITHUB_OUTPUT |
| 62 | +
|
| 63 | + - name: Docker CNTK meta |
| 64 | + id: cntk-meta |
| 65 | + uses: docker/metadata-action@v4 |
| 66 | + with: |
| 67 | + # list of Docker images to use as base name for tags |
| 68 | + images: | |
| 69 | + ${{vars.IMAGE_BASE}} |
| 70 | + # Docker tags based on the following events/attributes |
| 71 | + tags: | |
| 72 | + type=raw,value=${{ steps.variables.outputs.release-tag }},enable=${{ steps.variables.outputs.release-tag-enabled }} |
| 73 | + type=raw,value=latest |
| 74 | +
|
| 75 | + - name: Build and push |
| 76 | + uses: docker/build-push-action@v3 |
| 77 | + with: |
| 78 | + context: . |
| 79 | + file: Dockerfile |
| 80 | + push: ${{ github.event_name != 'pull_request' }} |
| 81 | + platforms: linux/amd64,linux/arm64 |
| 82 | + tags: ${{ steps.cntk-meta.outputs.tags }} |
| 83 | + labels: ${{ steps.cntk-meta.outputs.labels }} |
| 84 | + |
| 85 | + notify: |
| 86 | + needs: ["build"] |
| 87 | + runs-on: ubuntu-latest |
| 88 | + if: ${{ github.event_name != 'pull_request' }} |
| 89 | + |
| 90 | + strategy: |
| 91 | + matrix: |
| 92 | + repo: |
| 93 | + - ${{ github.repository }} |
| 94 | + |
| 95 | + steps: |
| 96 | + - name: Repository dispatch ${{ matrix.repo }} |
| 97 | + uses: cloud-native-toolkit/action-repository-dispatch@main |
| 98 | + with: |
| 99 | + notifyRepo: ${{ matrix.repo }} |
| 100 | + eventType: released |
| 101 | + env: |
| 102 | + GITHUB_TOKEN: ${{ secrets.TOKEN }} |
0 commit comments