|
| 1 | +name: ci |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: ["docker-build"] |
| 6 | + |
| 7 | +env: |
| 8 | + REGISTRY_IMAGE: sourcegraph/scip-clang |
| 9 | + |
| 10 | +jobs: |
| 11 | + build: |
| 12 | + runs-on: ubuntu-latest |
| 13 | + strategy: |
| 14 | + fail-fast: false |
| 15 | + matrix: |
| 16 | + platform: |
| 17 | + - linux/amd64 |
| 18 | + - linux/arm64 |
| 19 | + steps: |
| 20 | + - name: Prepare |
| 21 | + run: | |
| 22 | + platform=${{ matrix.platform }} |
| 23 | + echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV |
| 24 | +
|
| 25 | + - name: Docker meta |
| 26 | + id: meta |
| 27 | + uses: docker/metadata-action@v5 |
| 28 | + with: |
| 29 | + images: ${{ env.REGISTRY_IMAGE }} |
| 30 | + |
| 31 | + - name: Login to Docker Hub |
| 32 | + uses: docker/login-action@v3 |
| 33 | + with: |
| 34 | + username: ${{ vars.DOCKERHUB_USERNAME }} |
| 35 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 36 | + |
| 37 | + - name: Set up QEMU |
| 38 | + uses: docker/setup-qemu-action@v3 |
| 39 | + |
| 40 | + - name: Set up Docker Buildx |
| 41 | + uses: docker/setup-buildx-action@v3 |
| 42 | + |
| 43 | + - name: Build and push by digest |
| 44 | + id: build |
| 45 | + uses: docker/build-push-action@v6 |
| 46 | + with: |
| 47 | + platforms: ${{ matrix.platform }} |
| 48 | + labels: ${{ steps.meta.outputs.labels }} |
| 49 | + tags: ${{ env.REGISTRY_IMAGE }} |
| 50 | + outputs: type=image,push-by-digest=true,name-canonical=true,push=true |
| 51 | + |
| 52 | + - name: Export digest |
| 53 | + run: | |
| 54 | + mkdir -p ${{ runner.temp }}/digests |
| 55 | + digest="${{ steps.build.outputs.digest }}" |
| 56 | + touch "${{ runner.temp }}/digests/${digest#sha256:}" |
| 57 | +
|
| 58 | + - name: Upload digest |
| 59 | + uses: actions/upload-artifact@v4 |
| 60 | + with: |
| 61 | + name: digests-${{ env.PLATFORM_PAIR }} |
| 62 | + path: ${{ runner.temp }}/digests/* |
| 63 | + if-no-files-found: error |
| 64 | + retention-days: 1 |
| 65 | + |
| 66 | + merge: |
| 67 | + runs-on: ubuntu-latest |
| 68 | + needs: |
| 69 | + - build |
| 70 | + steps: |
| 71 | + - name: Download digests |
| 72 | + uses: actions/download-artifact@v4 |
| 73 | + with: |
| 74 | + path: ${{ runner.temp }}/digests |
| 75 | + pattern: digests-* |
| 76 | + merge-multiple: true |
| 77 | + |
| 78 | + - name: Login to Docker Hub |
| 79 | + uses: docker/login-action@v3 |
| 80 | + with: |
| 81 | + username: ${{ vars.DOCKERHUB_USERNAME }} |
| 82 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 83 | + |
| 84 | + - name: Set up Docker Buildx |
| 85 | + uses: docker/setup-buildx-action@v3 |
| 86 | + |
| 87 | + - name: Snapshot metadata |
| 88 | + if: github.ref == 'refs/heads/docker-build' |
| 89 | + uses: docker/metadata-action@v5 |
| 90 | + with: |
| 91 | + push: true |
| 92 | + tags: | |
| 93 | + type=raw,value=latest-snapshot |
| 94 | +
|
| 95 | + - name: Tag metadata |
| 96 | + if: startsWith(github.ref, 'refs/tags/v') |
| 97 | + uses: docker/metadata-action@v5 |
| 98 | + with: |
| 99 | + push: true |
| 100 | + tags: | |
| 101 | + type=raw,value=latest |
| 102 | + type=raw,value=${{ env.PATCH }} |
| 103 | + type=raw,value=${{ env.MINOR }} |
| 104 | + type=raw,value=${{ env.MAJOR }} |
| 105 | +
|
| 106 | + # - name: Create manifest list and push |
| 107 | + # working-directory: ${{ runner.temp }}/digests |
| 108 | + # run: | |
| 109 | + # docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ |
| 110 | + # $(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *) |
| 111 | + |
| 112 | + # - name: Inspect image |
| 113 | + # run: | |
| 114 | + # docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }} |
0 commit comments