chore(attribution): add OpenRouter attribution headers to AIr-Friends #307
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: Docker Publish Latest | |
| on: | |
| push: | |
| branches: | |
| - master | |
| workflow_dispatch: | |
| # Sets the permissions granted to the GITHUB_TOKEN for the actions in this job. | |
| permissions: | |
| contents: read | |
| packages: write | |
| id-token: write | |
| attestations: write | |
| env: | |
| IMAGE_NAME: air-friends | |
| jobs: | |
| build: | |
| name: Build (${{ matrix.platform }}) | |
| runs-on: ${{ matrix.runner }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - platform: linux/amd64 | |
| runner: ubuntu-latest | |
| - platform: linux/arm64 | |
| runner: ubuntu-24.04-arm | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Prepare platform variables | |
| run: | | |
| platform=${{ matrix.platform }} | |
| echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV | |
| - name: Setup Docker | |
| id: setup | |
| uses: ./.github/workflows/docker-reused-setup-steps | |
| with: | |
| DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} | |
| DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} | |
| QUAY_USERNAME: ${{ secrets.QUAY_USERNAME }} | |
| QUAY_TOKEN: ${{ secrets.QUAY_TOKEN }} | |
| tag: latest | |
| - name: Build and push by digest | |
| id: build | |
| uses: docker/build-push-action@v7 | |
| with: | |
| context: . | |
| file: ./Containerfile | |
| push: true | |
| target: final | |
| platforms: ${{ matrix.platform }} | |
| labels: ${{ steps.setup.outputs.labels }} | |
| build-args: | | |
| VERSION=latest | |
| RELEASE=${{ github.run_number }} | |
| cache-from: type=registry,ref=ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:cache-${{ env.PLATFORM_PAIR }} | |
| cache-to: type=registry,ref=ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:cache-${{ env.PLATFORM_PAIR }},mode=max | |
| outputs: | | |
| type=image,"name=ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }},${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }},quay.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}",push-by-digest=true,name-canonical=true,push=true | |
| sbom: true | |
| provenance: true | |
| - name: Export digest | |
| run: | | |
| mkdir -p /tmp/digests | |
| digest="${{ steps.build.outputs.digest }}" | |
| echo "${digest#sha256:}" > /tmp/digests/${{ env.PLATFORM_PAIR }} | |
| - name: Upload digest | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: digests-latest-${{ env.PLATFORM_PAIR }} | |
| path: /tmp/digests/* | |
| if-no-files-found: error | |
| retention-days: 1 | |
| merge: | |
| name: Merge Manifests | |
| runs-on: ubuntu-latest | |
| needs: build | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Download digests | |
| uses: actions/download-artifact@v8 | |
| with: | |
| path: /tmp/digests | |
| pattern: digests-latest-* | |
| merge-multiple: true | |
| - name: Setup Docker | |
| id: setup | |
| uses: ./.github/workflows/docker-reused-setup-steps | |
| with: | |
| DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} | |
| DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} | |
| QUAY_USERNAME: ${{ secrets.QUAY_USERNAME }} | |
| QUAY_TOKEN: ${{ secrets.QUAY_TOKEN }} | |
| tag: latest | |
| - name: Create manifest list and push to all registries | |
| run: | | |
| echo "Creating multi-arch manifest list..." | |
| cd /tmp/digests | |
| echo "Files in /tmp/digests:" | |
| ls -la | |
| digest_refs="" | |
| for file in linux-*; do | |
| if [[ -f "$file" ]]; then | |
| digest=$(cat "$file") | |
| echo "Processing $file with digest: $digest" | |
| digest_refs+="ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}@sha256:$digest " | |
| fi | |
| done | |
| echo "Final digest references: $digest_refs" | |
| docker buildx imagetools create \ | |
| $(jq -cr '.tags | map("-t " + .) | join(" ")' <<<"$DOCKER_METADATA_OUTPUT_JSON") \ | |
| $digest_refs | |
| - name: Get final manifest digest | |
| id: get_digest | |
| run: | | |
| IMAGE_TAG=$(jq -cr '.tags[] | select(startswith("ghcr.io/"))' <<<"$DOCKER_METADATA_OUTPUT_JSON" | head -n1) | |
| echo "Using tag for digest lookup: $IMAGE_TAG" | |
| DIGEST_RAW=$(docker buildx imagetools inspect "$IMAGE_TAG" --format "{{.Manifest.Digest}}") | |
| echo "Raw digest output: $DIGEST_RAW" | |
| DIGEST=$(echo "$DIGEST_RAW" | grep -oE 'sha256:[a-f0-9]{64}' | head -n1) | |
| echo "Extracted digest: $DIGEST" | |
| echo "manifest_digest=$DIGEST" >> $GITHUB_OUTPUT | |
| - name: Add attestations for GitHub Container Registry | |
| uses: actions/attest-build-provenance@v3 | |
| with: | |
| subject-name: ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }} | |
| subject-digest: ${{ steps.get_digest.outputs.manifest_digest }} | |
| - name: Add attestations for DockerHub | |
| uses: actions/attest-build-provenance@v3 | |
| with: | |
| subject-name: index.docker.io/${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }} | |
| subject-digest: ${{ steps.get_digest.outputs.manifest_digest }} | |
| - name: Add attestations for Quay | |
| uses: actions/attest-build-provenance@v3 | |
| with: | |
| subject-name: quay.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }} | |
| subject-digest: ${{ steps.get_digest.outputs.manifest_digest }} |