|
| 1 | +name: preview |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + |
| 6 | +jobs: |
| 7 | + publish: |
| 8 | + runs-on: ubuntu-latest-32-cores |
| 9 | + |
| 10 | + steps: |
| 11 | + - name: Set up Docker Buildx |
| 12 | + uses: docker/setup-buildx-action@v3 |
| 13 | + |
| 14 | + - name: Cache Docker layers |
| 15 | + uses: actions/cache@v4 |
| 16 | + with: |
| 17 | + path: /tmp/.buildx-cache/prebuild |
| 18 | + key: ${{ runner.os }}-buildx-${{ github.ref_name }}-${{ github.sha }} |
| 19 | + restore-keys: | |
| 20 | + ${{ runner.os }}-buildx-${{ github.ref_name }} |
| 21 | + ${{ runner.os }}-buildx- |
| 22 | +
|
| 23 | + - name: Cache Docker layers |
| 24 | + uses: actions/cache@v4 |
| 25 | + with: |
| 26 | + path: /tmp/.buildx-cache/build |
| 27 | + key: ${{ runner.os }}-buildx-${{ github.ref_name }}-${{ github.sha }} |
| 28 | + restore-keys: | |
| 29 | + ${{ runner.os }}-buildx-${{ github.ref_name }} |
| 30 | + ${{ runner.os }}-buildx- |
| 31 | +
|
| 32 | + - name: Checkout repository |
| 33 | + uses: actions/checkout@v4 |
| 34 | + |
| 35 | + - name: Login to GitHub Container Registry |
| 36 | + uses: docker/login-action@v3 |
| 37 | + with: |
| 38 | + registry: ghcr.io |
| 39 | + username: ${{ github.actor }} |
| 40 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 41 | + |
| 42 | + - name: Set outputs |
| 43 | + id: vars |
| 44 | + run: | |
| 45 | + set -eux |
| 46 | + git config --global --add safe.directory "${{ github.workspace }}" |
| 47 | + echo "sha_short=$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT" |
| 48 | +
|
| 49 | + - name: Build Docker image |
| 50 | + uses: docker/build-push-action@v5 |
| 51 | + with: |
| 52 | + context: . |
| 53 | + file: .github/Dockerfile |
| 54 | + load: true |
| 55 | + tags: build-local:latest |
| 56 | + cache-from: type=local,src=/tmp/.buildx-cache/prebuild |
| 57 | + cache-to: type=local,dest=/tmp/.buildx-cache-new/prebuild,mode=max |
| 58 | + platforms: linux/amd64 |
| 59 | + |
| 60 | + - name: Build local binaries |
| 61 | + run: | |
| 62 | + set -eux |
| 63 | + docker run --rm -v "$(pwd)/artifacts/$PLATFORM:/artifacts" build-local:latest /bin/sh -c "cp -r /app/artifacts/* /artifacts/" |
| 64 | + env: |
| 65 | + PLATFORM: linux/amd64 |
| 66 | + |
| 67 | + - name: Build and push docker image |
| 68 | + uses: docker/build-push-action@v3 |
| 69 | + with: |
| 70 | + push: true |
| 71 | + tags: ghcr.io/${{ github.repository }}:preview--${{ steps.vars.outputs.sha_short }} |
| 72 | + cache-from: type=local,src=/tmp/.buildx-cache/build |
| 73 | + cache-to: type=local,dest=/tmp/.buildx-cache-new/build,mode=max |
| 74 | + platforms: linux/amd64 |
| 75 | + build-contexts: | |
| 76 | + artifacts=artifacts |
| 77 | +
|
| 78 | + - # Temp fix |
| 79 | + # https://github.com/docker/build-push-action/issues/252 |
| 80 | + # https://github.com/moby/buildkit/issues/1896 |
| 81 | + name: Move cache |
| 82 | + run: | |
| 83 | + rm -rf /tmp/.buildx-cache/prebuild |
| 84 | + mv /tmp/.buildx-cache-new/prebuild /tmp/.buildx-cache/prebuild |
| 85 | + rm -rf /tmp/.buildx-cache/build |
| 86 | + mv /tmp/.buildx-cache-new/build /tmp/.buildx-cache/build |
0 commit comments