|
| 1 | +name: Release Docker Images |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + auth-server-released: |
| 7 | + description: 'Set to true to push docker images.' |
| 8 | + required: true |
| 9 | + type: boolean |
| 10 | + default: false |
| 11 | + custom-tag: |
| 12 | + description: 'Optional tag name to apply in addition to ref/sha tags.' |
| 13 | + required: false |
| 14 | + default: '' |
| 15 | + |
| 16 | +permissions: |
| 17 | + contents: read |
| 18 | + packages: write |
| 19 | + |
| 20 | +env: |
| 21 | + NODE_VERSION: '22.18.0' |
| 22 | + PNPM_VERSION: 9.15.0 |
| 23 | + |
| 24 | +jobs: |
| 25 | + docker-images: |
| 26 | + name: Build and Push |
| 27 | + if: ${{ github.event.inputs.auth-server-released == 'true' }} |
| 28 | + runs-on: ubuntu-latest |
| 29 | + strategy: |
| 30 | + matrix: |
| 31 | + app: [lit-auth-server, lit-login-server] |
| 32 | + steps: |
| 33 | + - name: Checkout |
| 34 | + uses: actions/checkout@v4 |
| 35 | + with: |
| 36 | + fetch-depth: 0 |
| 37 | + |
| 38 | + - name: Setup Node |
| 39 | + uses: actions/setup-node@v4 |
| 40 | + with: |
| 41 | + node-version: ${{ env.NODE_VERSION }} |
| 42 | + |
| 43 | + - name: Setup PNPM |
| 44 | + uses: pnpm/action-setup@v4 |
| 45 | + with: |
| 46 | + version: ${{ env.PNPM_VERSION }} |
| 47 | + |
| 48 | + - name: Install project dependencies |
| 49 | + run: pnpm install --frozen-lockfile |
| 50 | + |
| 51 | + - name: Set up Docker Buildx |
| 52 | + uses: docker/setup-buildx-action@v3 |
| 53 | + |
| 54 | + - name: Log in to GHCR |
| 55 | + uses: docker/login-action@v3 |
| 56 | + with: |
| 57 | + registry: ghcr.io |
| 58 | + username: ${{ secrets.GHCR_USERNAME || github.repository_owner }} |
| 59 | + password: ${{ secrets.GHCR_TOKEN || secrets.GITHUB_TOKEN }} |
| 60 | + |
| 61 | + - name: Extract Docker metadata |
| 62 | + id: meta |
| 63 | + uses: docker/metadata-action@v5 |
| 64 | + with: |
| 65 | + images: ghcr.io/lit-protocol/${{ matrix.app }} |
| 66 | + tags: | |
| 67 | + type=ref,event=branch |
| 68 | + type=ref,event=tag |
| 69 | + type=sha |
| 70 | + type=raw,value=latest |
| 71 | +
|
| 72 | + - name: Build image with Nx target |
| 73 | + run: pnpm nx run ${{ matrix.app }}:docker-build |
| 74 | + |
| 75 | + - name: Tag and push image |
| 76 | + env: |
| 77 | + IMAGE_NAME: ${{ matrix.app }} |
| 78 | + TAGS: ${{ steps.meta.outputs.tags }} |
| 79 | + CUSTOM_TAG: ${{ github.event.inputs.custom-tag }} |
| 80 | + run: | |
| 81 | + tags_to_push="$TAGS" |
| 82 | + if [ -n "$CUSTOM_TAG" ]; then |
| 83 | + tags_to_push="$tags_to_push"$'\n'"ghcr.io/lit-protocol/${IMAGE_NAME}:$CUSTOM_TAG" |
| 84 | + fi |
| 85 | + echo "$tags_to_push" | while IFS= read -r tag; do |
| 86 | + [ -z "$tag" ] && continue |
| 87 | + docker tag "$IMAGE_NAME" "$tag" |
| 88 | + docker push "$tag" |
| 89 | + done |
| 90 | +
|
| 91 | + skip: |
| 92 | + name: Skip Docker Release |
| 93 | + if: ${{ github.event.inputs.auth-server-released != 'true' }} |
| 94 | + runs-on: ubuntu-latest |
| 95 | + steps: |
| 96 | + - run: echo "Skipping docker image publish because auth-server release flag is false." |
0 commit comments