|
1 | 1 | name: Publish docker images |
2 | 2 | on: |
3 | 3 | workflow_dispatch: |
| 4 | +env: |
| 5 | + IMAGE_NAME: discordjs/proxy |
4 | 6 | jobs: |
5 | | - docker-publish: |
6 | | - name: Docker publish |
7 | | - runs-on: ubuntu-latest |
| 7 | + build: |
| 8 | + name: Build ${{ matrix.platform }} |
| 9 | + runs-on: ${{ matrix.runner }} |
| 10 | + strategy: |
| 11 | + fail-fast: false |
| 12 | + matrix: |
| 13 | + include: |
| 14 | + - platform: linux/amd64 |
| 15 | + runner: ubuntu-latest |
| 16 | + - platform: linux/arm64 |
| 17 | + runner: ubuntu-24.04-arm |
8 | 18 | steps: |
| 19 | + - name: Prepare |
| 20 | + run: | |
| 21 | + platform=${{ matrix.platform }} |
| 22 | + echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV |
| 23 | +
|
9 | 24 | - name: Checkout repository |
10 | | - uses: actions/checkout@v5 |
| 25 | + uses: actions/checkout@v6 |
| 26 | + |
| 27 | + - name: Set up Docker Buildx |
| 28 | + uses: docker/setup-buildx-action@v3 |
11 | 29 |
|
12 | | - - name: Install Node.js v24 |
13 | | - uses: actions/setup-node@v6 |
| 30 | + - name: Login to DockerHub |
| 31 | + uses: docker/login-action@v3 |
| 32 | + with: |
| 33 | + username: ${{ secrets.DOCKER_USERNAME }} |
| 34 | + password: ${{ secrets.DOCKER_ACCESS_TOKEN }} |
| 35 | + |
| 36 | + - name: Build and push by digest |
| 37 | + id: build |
| 38 | + uses: docker/build-push-action@v6 |
14 | 39 | with: |
15 | | - node-version: 24 |
16 | | - package-manager-cache: false |
| 40 | + context: . |
| 41 | + file: packages/proxy-container/Dockerfile |
| 42 | + platforms: ${{ matrix.platform }} |
| 43 | + outputs: type=image,name=${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true |
17 | 44 |
|
18 | | - - name: Install dependencies |
19 | | - uses: ./packages/actions/src/pnpmCache |
| 45 | + - name: Export digest |
| 46 | + run: | |
| 47 | + mkdir -p /tmp/digests |
| 48 | + digest="${{ steps.build.outputs.digest }}" |
| 49 | + touch "/tmp/digests/${digest#sha256:}" |
| 50 | +
|
| 51 | + - name: Upload digest |
| 52 | + uses: actions/upload-artifact@v5 |
| 53 | + with: |
| 54 | + name: digests-${{ env.PLATFORM_PAIR }} |
| 55 | + path: /tmp/digests/* |
| 56 | + if-no-files-found: error |
| 57 | + retention-days: 1 |
| 58 | + |
| 59 | + merge: |
| 60 | + name: Create and push manifest list |
| 61 | + runs-on: ubuntu-latest |
| 62 | + needs: build |
| 63 | + steps: |
| 64 | + - name: Download digests |
| 65 | + uses: actions/download-artifact@v6 |
| 66 | + with: |
| 67 | + path: /tmp/digests |
| 68 | + pattern: digests-* |
| 69 | + merge-multiple: true |
| 70 | + |
| 71 | + - name: Checkout repository |
| 72 | + uses: actions/checkout@v6 |
| 73 | + |
| 74 | + - name: Get Major Version |
| 75 | + id: version |
| 76 | + run: | |
| 77 | + FULL_VER=$(jq --raw-output '.version' packages/proxy-container/package.json) |
| 78 | + MAJOR=$(echo $FULL_VER | cut -d '.' -f1) |
| 79 | + echo "major=$MAJOR" >> $GITHUB_OUTPUT |
20 | 80 |
|
21 | 81 | - name: Set up Docker Buildx |
22 | 82 | uses: docker/setup-buildx-action@v3 |
23 | 83 |
|
24 | 84 | - name: Login to DockerHub |
25 | | - run: echo ${{ secrets.DOCKER_ACCESS_TOKEN }} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin |
| 85 | + uses: docker/login-action@v3 |
| 86 | + with: |
| 87 | + username: ${{ secrets.DOCKER_USERNAME }} |
| 88 | + password: ${{ secrets.DOCKER_ACCESS_TOKEN }} |
| 89 | + |
| 90 | + - name: Create manifest list and push |
| 91 | + working-directory: /tmp/digests |
| 92 | + run: | |
| 93 | + docker buildx imagetools create -t ${{ env.IMAGE_NAME }}:${{ steps.version.outputs.major }} \ |
| 94 | + $(printf '${{ env.IMAGE_NAME }}@sha256:%s ' *) |
26 | 95 |
|
27 | | - - name: Build & push docker image |
28 | | - run: docker build -f packages/proxy-container/Dockerfile -t discordjs/proxy:$(cut -d '.' -f1 <<< $(jq --raw-output '.version' packages/proxy-container/package.json)) --push . |
| 96 | + - name: Inspect image |
| 97 | + run: | |
| 98 | + docker buildx imagetools inspect ${{ env.IMAGE_NAME }}:${{ steps.version.outputs.major }} |
0 commit comments