|
| 1 | +name: ci |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - "**" |
| 7 | + tags: |
| 8 | + - "v*.*.*" |
| 9 | + workflow_dispatch: |
| 10 | + |
| 11 | +jobs: |
| 12 | + build: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + strategy: |
| 15 | + fail-fast: false |
| 16 | + matrix: |
| 17 | + platform: |
| 18 | + - linux/amd64 |
| 19 | + - linux/arm/v6 |
| 20 | + - linux/arm/v7 |
| 21 | + - linux/arm64 |
| 22 | + |
| 23 | + steps: |
| 24 | + - name: Checkout code |
| 25 | + uses: actions/checkout@v4 |
| 26 | + |
| 27 | + - name: Set Environment Variables |
| 28 | + run: | |
| 29 | + echo "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_ENV |
| 30 | + echo "VCS_REF=$(git rev-parse --short HEAD)" >> $GITHUB_ENV |
| 31 | +
|
| 32 | + - name: Docker meta |
| 33 | + id: meta |
| 34 | + uses: docker/metadata-action@v5 |
| 35 | + with: |
| 36 | + images: | |
| 37 | + ghcr.io/${{ github.repository_owner }}/docker-nginx-http3 |
| 38 | +
|
| 39 | + - name: Set up QEMU |
| 40 | + uses: docker/setup-qemu-action@v3 |
| 41 | + |
| 42 | + - name: Set up Docker Buildx |
| 43 | + uses: docker/setup-buildx-action@v3 |
| 44 | + |
| 45 | + - name: Login to GitHub Container Registry |
| 46 | + if: github.event_name != 'pull_request' |
| 47 | + uses: docker/login-action@v3 |
| 48 | + with: |
| 49 | + registry: ghcr.io |
| 50 | + username: ${{ github.repository_owner }} |
| 51 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 52 | + |
| 53 | + - name: Docker build and push |
| 54 | + id: build |
| 55 | + uses: docker/build-push-action@v5 |
| 56 | + with: |
| 57 | + context: . |
| 58 | + platforms: ${{ matrix.platform }} |
| 59 | + push: ${{ github.event_name != 'pull_request' }} |
| 60 | + labels: ${{ steps.meta.outputs.labels }} |
| 61 | + tags: ${{ steps.meta.outputs.tags }} |
| 62 | + build-args: | |
| 63 | + BUILD_DATE=${{ env.BUILD_DATE }} |
| 64 | + VCS_REF=${{ env.VCS_REF }} |
| 65 | + GITHUB_REF=${{ github.ref }} |
| 66 | + GITHUB_RUN_ID=${{ github.run_id }} |
| 67 | + GITHUB_RUN_NUMBER=${{ github.run_number }} |
| 68 | + GITHUB_RUN_ATTEMPT=${{ github.run_attempt }} |
| 69 | +
|
| 70 | + - name: Export digest |
| 71 | + run: | |
| 72 | + mkdir -p /tmp/digests |
| 73 | + digest="${{ steps.build.outputs.digest }}" |
| 74 | + touch "/tmp/digests/${digest#sha256:}" |
| 75 | +
|
| 76 | + - name: Upload digest |
| 77 | + uses: actions/upload-artifact@v3 |
| 78 | + with: |
| 79 | + name: digests |
| 80 | + path: /tmp/digests/* |
| 81 | + if-no-files-found: error |
| 82 | + retention-days: 1 |
| 83 | + |
| 84 | + merge: |
| 85 | + runs-on: ubuntu-latest |
| 86 | + needs: |
| 87 | + - build |
| 88 | + steps: |
| 89 | + - name: Download digests |
| 90 | + uses: actions/download-artifact@v3 |
| 91 | + with: |
| 92 | + name: digests |
| 93 | + path: /tmp/digests |
| 94 | + |
| 95 | + - name: Set up Docker Buildx |
| 96 | + uses: docker/setup-buildx-action@v3 |
| 97 | + |
| 98 | + - name: Docker meta |
| 99 | + id: meta |
| 100 | + uses: docker/metadata-action@v5 |
| 101 | + with: |
| 102 | + images: | |
| 103 | + ghcr.io/${{ github.repository_owner }}/docker-nginx-http3 |
| 104 | + tags: | |
| 105 | + type=schedule |
| 106 | + type=ref,event=branch |
| 107 | + type=ref,event=tag |
| 108 | + type=semver,pattern={{version}} |
| 109 | + type=semver,pattern={{major}}.{{minor}} |
| 110 | + type=semver,pattern={{major}} |
| 111 | + type=sha,prefix= |
| 112 | + type=sha,prefix=,format=long |
| 113 | +
|
| 114 | + - name: Login to GitHub Container Registry |
| 115 | + if: github.event_name != 'pull_request' |
| 116 | + uses: docker/login-action@v3 |
| 117 | + with: |
| 118 | + registry: ghcr.io |
| 119 | + username: ${{ github.repository_owner }} |
| 120 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 121 | + |
| 122 | + - name: Create manifest list and push |
| 123 | + if: github.event_name != 'pull_request' |
| 124 | + working-directory: /tmp/digests |
| 125 | + run: | |
| 126 | + docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ |
| 127 | + $(printf 'ghcr.io/${{ github.repository_owner }}/docker-nginx-http3@sha256:%s ' *) |
| 128 | +
|
| 129 | + - name: Inspect images |
| 130 | + run: | |
| 131 | + docker buildx imagetools inspect ghcr.io/${{ github.repository_owner }}/docker-nginx-http3:${{ steps.meta.outputs.version }} |
0 commit comments