|
| 1 | +name: build chatbot-rag-app image |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + paths: |
| 8 | + - example-apps/chatbot-rag-app/** |
| 9 | + - .github/workflows/docker-chatbot-rag-app.yml |
| 10 | + - '!**/*.md' |
| 11 | + pull_request: |
| 12 | + branches: |
| 13 | + - main |
| 14 | + paths: |
| 15 | + # Verify changes to the Dockerfile on PRs |
| 16 | + - example-apps/chatbot-rag-app/Dockerfile |
| 17 | + - .github/workflows/docker-chatbot-rag-app.yml |
| 18 | + - '!**/*.md' |
| 19 | + workflow_dispatch: |
| 20 | + |
| 21 | +permissions: |
| 22 | + contents: read |
| 23 | + packages: write |
| 24 | + |
| 25 | +env: |
| 26 | + IMAGE: ghcr.io/${{ github.repository }}/chatbot-rag-app |
| 27 | + |
| 28 | +jobs: |
| 29 | + build-image: |
| 30 | + strategy: |
| 31 | + matrix: |
| 32 | + runner: |
| 33 | + - ubuntu-24.04 |
| 34 | + - ubuntu-24.04-arm |
| 35 | + runs-on: ${{ matrix.runner }} |
| 36 | + steps: |
| 37 | + - uses: actions/checkout@v4 |
| 38 | + - uses: docker/setup-buildx-action@v3 |
| 39 | + - uses: docker/login-action@v3 |
| 40 | + if: github.event_name == 'push' |
| 41 | + with: |
| 42 | + registry: ghcr.io |
| 43 | + username: ${{ github.actor }} |
| 44 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 45 | + - uses: docker/build-push-action@v6 |
| 46 | + id: build |
| 47 | + with: |
| 48 | + context: example-apps/chatbot-rag-app |
| 49 | + outputs: type=image,name=${{ env.IMAGE }},push-by-digest=true,name-canonical=true,push=${{ github.event_name == 'push' && 'true' || 'false' }} |
| 50 | + cache-from: type=gha |
| 51 | + cache-to: type=gha,mode=max |
| 52 | + - name: export digest |
| 53 | + if: github.event_name == 'push' |
| 54 | + run: | |
| 55 | + mkdir -p /tmp/digests |
| 56 | + digest="${{ steps.build.outputs.digest }}" |
| 57 | + touch "/tmp/digests/${digest#sha256:}" |
| 58 | + - name: upload digest |
| 59 | + if: github.event_name == 'push' |
| 60 | + uses: actions/upload-artifact@v4 |
| 61 | + with: |
| 62 | + name: digests-${{ matrix.runner }} |
| 63 | + path: /tmp/digests/* |
| 64 | + if-no-files-found: error |
| 65 | + retention-days: 1 |
| 66 | + |
| 67 | + push-manifest: |
| 68 | + runs-on: ubuntu-24.04 |
| 69 | + needs: build-image |
| 70 | + if: github.event_name == 'push' |
| 71 | + steps: |
| 72 | + - uses: actions/checkout@v4 |
| 73 | + - uses: docker/setup-buildx-action@v3 |
| 74 | + - uses: docker/login-action@v3 |
| 75 | + with: |
| 76 | + registry: ghcr.io |
| 77 | + username: ${{ github.actor }} |
| 78 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 79 | + - name: Docker meta |
| 80 | + id: meta |
| 81 | + uses: docker/metadata-action@v5 |
| 82 | + with: |
| 83 | + images: ${{ env.IMAGE }} |
| 84 | + tags: | |
| 85 | + type=raw,latest |
| 86 | + type=sha,format=long |
| 87 | + - name: Download digests |
| 88 | + uses: actions/download-artifact@v4 |
| 89 | + with: |
| 90 | + path: /tmp/digests |
| 91 | + pattern: digests-* |
| 92 | + merge-multiple: true |
| 93 | + - run: ls /tmp/digests |
| 94 | + - name: Create manifest list and push |
| 95 | + working-directory: /tmp/digests |
| 96 | + run: | |
| 97 | + docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ |
| 98 | + $(printf '${{ env.IMAGE }}@sha256:%s ' *) |
| 99 | + - name: Inspect image to verify |
| 100 | + run: | |
| 101 | + docker buildx imagetools inspect ${{ env.IMAGE }}:${{ steps.meta.outputs.version }} |
0 commit comments