fix: create nginx cache directory #387
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and Push Docker Images (Default + Simple Mode) | |
| on: | |
| push: | |
| branches: | |
| - "main" | |
| tags: | |
| - "v*" | |
| workflow_dispatch: | |
| jobs: | |
| # New job to build dist and create release | |
| build-and-release: | |
| runs-on: ubuntu-latest | |
| if: github.repository == 'alam00000/bentopdf' && startsWith(github.ref, 'refs/tags/') | |
| permissions: | |
| contents: write | |
| env: | |
| HUSKY: 0 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build distribution | |
| run: npm run build | |
| - name: Extract version | |
| id: version | |
| run: | | |
| VERSION=${GITHUB_REF#refs/tags/v} | |
| echo "version=${VERSION}" >> $GITHUB_OUTPUT | |
| - name: Package distribution | |
| run: npm run package | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: dist-${{ steps.version.outputs.version }}.zip | |
| generate_release_notes: true | |
| draft: false | |
| prerelease: false | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| # Build each platform natively in parallel, then merge manifests | |
| build-amd64: | |
| runs-on: ubuntu-latest | |
| if: github.repository == 'alam00000/bentopdf' | |
| permissions: | |
| contents: read | |
| packages: write | |
| strategy: | |
| matrix: | |
| mode: | |
| - name: default | |
| simple_mode: false | |
| suffix: "" | |
| - name: simple | |
| simple_mode: true | |
| suffix: "-simple" | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.repository_owner }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract version | |
| id: version | |
| run: | | |
| if [[ $GITHUB_REF == refs/tags/v* ]]; then | |
| VERSION=${GITHUB_REF#refs/tags/} | |
| echo "version=${VERSION}" >> $GITHUB_OUTPUT | |
| echo "version_without_v=${VERSION#v}" >> $GITHUB_OUTPUT | |
| echo "is_release=true" >> $GITHUB_OUTPUT | |
| else | |
| SHORT_SHA=${GITHUB_SHA::7} | |
| echo "version=edge" >> $GITHUB_OUTPUT | |
| echo "short_sha=${SHORT_SHA}" >> $GITHUB_OUTPUT | |
| echo "is_release=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Build and push amd64 ${{ matrix.mode.name }} (release) | |
| if: steps.version.outputs.is_release == 'true' | |
| uses: docker/build-push-action@v6 | |
| with: | |
| push: true | |
| build-args: | | |
| SIMPLE_MODE=${{ matrix.mode.simple_mode }} | |
| tags: | | |
| ghcr.io/${{ github.repository_owner }}/bentopdf${{ matrix.mode.suffix }}:${{ steps.version.outputs.version }}-amd64 | |
| platforms: linux/amd64 | |
| cache-from: type=gha,scope=amd64-${{ matrix.mode.name }} | |
| cache-to: type=gha,mode=max,scope=amd64-${{ matrix.mode.name }} | |
| - name: Build and push amd64 ${{ matrix.mode.name }} (edge) | |
| if: steps.version.outputs.is_release == 'false' | |
| uses: docker/build-push-action@v6 | |
| with: | |
| push: true | |
| build-args: | | |
| SIMPLE_MODE=${{ matrix.mode.simple_mode }} | |
| tags: | | |
| ghcr.io/${{ github.repository_owner }}/bentopdf${{ matrix.mode.suffix }}:edge-amd64 | |
| platforms: linux/amd64 | |
| cache-from: type=gha,scope=amd64-${{ matrix.mode.name }} | |
| cache-to: type=gha,mode=max,scope=amd64-${{ matrix.mode.name }} | |
| build-arm64: | |
| runs-on: ubuntu-24.04-arm # Native ARM64 runner | |
| permissions: | |
| contents: read | |
| packages: write | |
| strategy: | |
| matrix: | |
| mode: | |
| - name: default | |
| simple_mode: false | |
| suffix: "" | |
| - name: simple | |
| simple_mode: true | |
| suffix: "-simple" | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.repository_owner }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract version | |
| id: version | |
| run: | | |
| if [[ $GITHUB_REF == refs/tags/v* ]]; then | |
| VERSION=${GITHUB_REF#refs/tags/} | |
| echo "version=${VERSION}" >> $GITHUB_OUTPUT | |
| echo "version_without_v=${VERSION#v}" >> $GITHUB_OUTPUT | |
| echo "is_release=true" >> $GITHUB_OUTPUT | |
| else | |
| SHORT_SHA=${GITHUB_SHA::7} | |
| echo "version=edge" >> $GITHUB_OUTPUT | |
| echo "short_sha=${SHORT_SHA}" >> $GITHUB_OUTPUT | |
| echo "is_release=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Build and push arm64 ${{ matrix.mode.name }} (release) | |
| if: steps.version.outputs.is_release == 'true' | |
| uses: docker/build-push-action@v6 | |
| with: | |
| push: true | |
| build-args: | | |
| SIMPLE_MODE=${{ matrix.mode.simple_mode }} | |
| tags: | | |
| ghcr.io/${{ github.repository_owner }}/bentopdf${{ matrix.mode.suffix }}:${{ steps.version.outputs.version }}-arm64 | |
| platforms: linux/arm64 | |
| cache-from: type=gha,scope=arm64-${{ matrix.mode.name }} | |
| cache-to: type=gha,mode=max,scope=arm64-${{ matrix.mode.name }} | |
| - name: Build and push arm64 ${{ matrix.mode.name }} (edge) | |
| if: steps.version.outputs.is_release == 'false' | |
| uses: docker/build-push-action@v6 | |
| with: | |
| push: true | |
| build-args: | | |
| SIMPLE_MODE=${{ matrix.mode.simple_mode }} | |
| tags: | | |
| ghcr.io/${{ github.repository_owner }}/bentopdf${{ matrix.mode.suffix }}:edge-arm64 | |
| platforms: linux/arm64 | |
| cache-from: type=gha,scope=arm64-${{ matrix.mode.name }} | |
| cache-to: type=gha,mode=max,scope=arm64-${{ matrix.mode.name }} | |
| # Merge GHCR manifests after both platforms are built | |
| merge-manifests-ghcr: | |
| runs-on: ubuntu-latest | |
| needs: [build-amd64, build-arm64] | |
| permissions: | |
| packages: write | |
| strategy: | |
| matrix: | |
| mode: | |
| - name: default | |
| suffix: "" | |
| - name: simple | |
| suffix: "-simple" | |
| steps: | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.repository_owner }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract version | |
| id: version | |
| run: | | |
| if [[ $GITHUB_REF == refs/tags/v* ]]; then | |
| VERSION=${GITHUB_REF#refs/tags/} | |
| echo "version=${VERSION}" >> $GITHUB_OUTPUT | |
| echo "version_without_v=${VERSION#v}" >> $GITHUB_OUTPUT | |
| echo "is_release=true" >> $GITHUB_OUTPUT | |
| else | |
| SHORT_SHA=${GITHUB_SHA::7} | |
| echo "version=edge" >> $GITHUB_OUTPUT | |
| echo "short_sha=${SHORT_SHA}" >> $GITHUB_OUTPUT | |
| echo "is_release=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Create and push GHCR manifest (release) | |
| if: steps.version.outputs.is_release == 'true' | |
| run: | | |
| docker buildx imagetools create -t ghcr.io/${{ github.repository_owner }}/bentopdf${{ matrix.mode.suffix }}:latest \ | |
| ghcr.io/${{ github.repository_owner }}/bentopdf${{ matrix.mode.suffix }}:${{ steps.version.outputs.version }}-amd64 \ | |
| ghcr.io/${{ github.repository_owner }}/bentopdf${{ matrix.mode.suffix }}:${{ steps.version.outputs.version }}-arm64 | |
| docker buildx imagetools create -t ghcr.io/${{ github.repository_owner }}/bentopdf${{ matrix.mode.suffix }}:${{ steps.version.outputs.version }} \ | |
| ghcr.io/${{ github.repository_owner }}/bentopdf${{ matrix.mode.suffix }}:${{ steps.version.outputs.version }}-amd64 \ | |
| ghcr.io/${{ github.repository_owner }}/bentopdf${{ matrix.mode.suffix }}:${{ steps.version.outputs.version }}-arm64 | |
| docker buildx imagetools create -t ghcr.io/${{ github.repository_owner }}/bentopdf${{ matrix.mode.suffix }}:${{ steps.version.outputs.version_without_v }} \ | |
| ghcr.io/${{ github.repository_owner }}/bentopdf${{ matrix.mode.suffix }}:${{ steps.version.outputs.version }}-amd64 \ | |
| ghcr.io/${{ github.repository_owner }}/bentopdf${{ matrix.mode.suffix }}:${{ steps.version.outputs.version }}-arm64 | |
| - name: Create and push GHCR manifest (edge) | |
| if: steps.version.outputs.is_release == 'false' | |
| run: | | |
| docker buildx imagetools create -t ghcr.io/${{ github.repository_owner }}/bentopdf${{ matrix.mode.suffix }}:edge \ | |
| ghcr.io/${{ github.repository_owner }}/bentopdf${{ matrix.mode.suffix }}:edge-amd64 \ | |
| ghcr.io/${{ github.repository_owner }}/bentopdf${{ matrix.mode.suffix }}:edge-arm64 | |
| docker buildx imagetools create -t ghcr.io/${{ github.repository_owner }}/bentopdf${{ matrix.mode.suffix }}:sha-${{ steps.version.outputs.short_sha }} \ | |
| ghcr.io/${{ github.repository_owner }}/bentopdf${{ matrix.mode.suffix }}:edge-amd64 \ | |
| ghcr.io/${{ github.repository_owner }}/bentopdf${{ matrix.mode.suffix }}:edge-arm64 | |
| # Copy images from GHCR to DockerHub | |
| push-to-dockerhub: | |
| runs-on: ubuntu-latest | |
| needs: [merge-manifests-ghcr] | |
| continue-on-error: true | |
| permissions: | |
| contents: read | |
| packages: read | |
| strategy: | |
| matrix: | |
| mode: | |
| - name: default | |
| suffix: "" | |
| - name: simple | |
| suffix: "-simple" | |
| steps: | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.repository_owner }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Login to DockerHub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_TOKEN }} | |
| - name: Extract version | |
| id: version | |
| run: | | |
| if [[ $GITHUB_REF == refs/tags/v* ]]; then | |
| VERSION=${GITHUB_REF#refs/tags/} | |
| echo "version=${VERSION}" >> $GITHUB_OUTPUT | |
| echo "version_without_v=${VERSION#v}" >> $GITHUB_OUTPUT | |
| echo "is_release=true" >> $GITHUB_OUTPUT | |
| else | |
| SHORT_SHA=${GITHUB_SHA::7} | |
| echo "version=edge" >> $GITHUB_OUTPUT | |
| echo "short_sha=${SHORT_SHA}" >> $GITHUB_OUTPUT | |
| echo "is_release=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Copy images to DockerHub (release) | |
| if: steps.version.outputs.is_release == 'true' | |
| run: | | |
| docker buildx imagetools create -t bentopdfteam/bentopdf${{ matrix.mode.suffix }}:latest \ | |
| ghcr.io/${{ github.repository_owner }}/bentopdf${{ matrix.mode.suffix }}:${{ steps.version.outputs.version }}-amd64 \ | |
| ghcr.io/${{ github.repository_owner }}/bentopdf${{ matrix.mode.suffix }}:${{ steps.version.outputs.version }}-arm64 | |
| docker buildx imagetools create -t bentopdfteam/bentopdf${{ matrix.mode.suffix }}:${{ steps.version.outputs.version }} \ | |
| ghcr.io/${{ github.repository_owner }}/bentopdf${{ matrix.mode.suffix }}:${{ steps.version.outputs.version }}-amd64 \ | |
| ghcr.io/${{ github.repository_owner }}/bentopdf${{ matrix.mode.suffix }}:${{ steps.version.outputs.version }}-arm64 | |
| docker buildx imagetools create -t bentopdfteam/bentopdf${{ matrix.mode.suffix }}:${{ steps.version.outputs.version_without_v }} \ | |
| ghcr.io/${{ github.repository_owner }}/bentopdf${{ matrix.mode.suffix }}:${{ steps.version.outputs.version }}-amd64 \ | |
| ghcr.io/${{ github.repository_owner }}/bentopdf${{ matrix.mode.suffix }}:${{ steps.version.outputs.version }}-arm64 | |
| - name: Copy images to DockerHub (edge) | |
| if: steps.version.outputs.is_release == 'false' | |
| run: | | |
| docker buildx imagetools create -t bentopdfteam/bentopdf${{ matrix.mode.suffix }}:edge \ | |
| ghcr.io/${{ github.repository_owner }}/bentopdf${{ matrix.mode.suffix }}:edge-amd64 \ | |
| ghcr.io/${{ github.repository_owner }}/bentopdf${{ matrix.mode.suffix }}:edge-arm64 | |
| docker buildx imagetools create -t bentopdfteam/bentopdf${{ matrix.mode.suffix }}:sha-${{ steps.version.outputs.short_sha }} \ | |
| ghcr.io/${{ github.repository_owner }}/bentopdf${{ matrix.mode.suffix }}:edge-amd64 \ | |
| ghcr.io/${{ github.repository_owner }}/bentopdf${{ matrix.mode.suffix }}:edge-arm64 |