More readable theme button component #527
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: 💫 Next.js Build and Push | |
| on: | |
| push: | |
| branches: [master] | |
| concurrency: | |
| group: environment-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| setup_env: | |
| name: ⚙️ Setup environment | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: Add SHORT_SHA env property | |
| run: echo "SHORT_SHA=`echo ${GITHUB_SHA::7}`" >> $GITHUB_ENV | |
| - name: Put commit msg in environment | |
| run: echo "COMMIT_MSG=${{ github.event.head_commit.message }}" >> $GITHUB_ENV | |
| - name: Escape commit message | |
| run: | | |
| echo "COMMIT_MSG=$(echo $COMMIT_MSG | tr -d \'\\\")" >> $GITHUB_ENV | |
| - name: Get branch name | |
| shell: bash | |
| run: echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/} | tr / -)" >> $GITHUB_ENV | |
| - name: Set build start in env variable | |
| run: echo "BUILD_START=$(date +%s)" >> $GITHUB_ENV | |
| outputs: | |
| short_sha: ${{ env.SHORT_SHA }} | |
| commit_msg: ${{ env.COMMIT_MSG }} | |
| branch_name: ${{ env.BRANCH_NAME }} | |
| build_start: ${{ env.BUILD_START }} | |
| build_and_push: | |
| name: 🔨 Build and Push Docker Images | |
| needs: setup_env | |
| strategy: | |
| matrix: | |
| include: | |
| - platform: linux/amd64 | |
| runs-on: ubuntu-24.04 | |
| arch: amd64 | |
| - platform: linux/arm64 | |
| runs-on: ubuntu-24.04-arm | |
| arch: arm64 | |
| runs-on: ${{ matrix.runs-on }} | |
| env: | |
| GITHUB_RUN_ID: ${{ github.run_id }} | |
| BUILDX_CACHE_DIR: /tmp/.buildx-cache | |
| steps: | |
| - uses: actions/checkout@v4 | |
| # Cache NPM dependencies | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "22" | |
| cache: "npm" | |
| - name: Install dependencies | |
| run: npm ci | |
| # Next.js build cache | |
| - name: Cache Next.js build | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| .next/cache | |
| key: ${{ runner.os }}-${{ matrix.arch }}-nextjs-${{ hashFiles('**/package-lock.json') }}-${{ github.sha }} | |
| restore-keys: | | |
| ${{ runner.os }}-${{ matrix.arch }}-nextjs-${{ hashFiles('**/package-lock.json') }}- | |
| ${{ runner.os }}-${{ matrix.arch }}-nextjs- | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Cache Docker layers | |
| uses: actions/cache@v4 | |
| with: | |
| path: ${{ env.BUILDX_CACHE_DIR }} | |
| key: ${{ runner.os }}-${{ matrix.arch }}-buildx-${{ github.sha }} | |
| restore-keys: | | |
| ${{ runner.os }}-${{ matrix.arch }}-buildx- | |
| - name: Login to registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and push image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| platforms: ${{ matrix.platform }} | |
| provenance: false | |
| push: true | |
| build-args: | | |
| VERSION=${{ needs.setup_env.outputs.short_sha }} | |
| COMMIT_MSG=${{ needs.setup_env.outputs.commit_msg }} | |
| BUILD_START=${{ needs.setup_env.outputs.build_start }} | |
| tags: ghcr.io/unbindapp/unbind-ui:${{ needs.setup_env.outputs.branch_name }}-${{ env.GITHUB_RUN_ID }}-${{ matrix.arch }} | |
| cache-from: | | |
| type=local,src=${{ env.BUILDX_CACHE_DIR }} | |
| type=registry,ref=ghcr.io/unbindapp/unbind-ui:cache-${{ needs.setup_env.outputs.branch_name }}-${{ matrix.arch }} | |
| cache-to: | | |
| type=local,dest=${{ env.BUILDX_CACHE_DIR }}-new,mode=max | |
| # Move cache to avoid growth | |
| - name: Move cache | |
| run: | | |
| rm -rf ${{ env.BUILDX_CACHE_DIR }} | |
| mv ${{ env.BUILDX_CACHE_DIR }}-new ${{ env.BUILDX_CACHE_DIR }} | |
| # Update the cache image in registry for future runs | |
| - name: Update cache image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| platforms: ${{ matrix.platform }} | |
| push: true | |
| tags: ghcr.io/unbindapp/unbind-ui:cache-${{ needs.setup_env.outputs.branch_name }}-${{ matrix.arch }} | |
| cache-from: type=local,src=${{ env.BUILDX_CACHE_DIR }} | |
| build-args: | | |
| VERSION=${{ needs.setup_env.outputs.short_sha }} | |
| COMMIT_MSG=${{ needs.setup_env.outputs.commit_msg }} | |
| BUILD_START=${{ needs.setup_env.outputs.build_start }} | |
| outputs: type=registry | |
| create_manifest: | |
| name: 📦 Create Multi-Arch Manifest | |
| runs-on: ubuntu-24.04 | |
| needs: [setup_env, build_and_push] | |
| env: | |
| GITHUB_RUN_ID: ${{ github.run_id }} | |
| steps: | |
| - name: Login to registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Create and push manifest | |
| run: | | |
| docker manifest create ghcr.io/unbindapp/unbind-ui:${{ needs.setup_env.outputs.branch_name }}-${{ env.GITHUB_RUN_ID }} \ | |
| --amend ghcr.io/unbindapp/unbind-ui:${{ needs.setup_env.outputs.branch_name }}-${{ env.GITHUB_RUN_ID }}-amd64 \ | |
| --amend ghcr.io/unbindapp/unbind-ui:${{ needs.setup_env.outputs.branch_name }}-${{ env.GITHUB_RUN_ID }}-arm64 | |
| docker manifest annotate --arch amd64 --os linux ghcr.io/unbindapp/unbind-ui:${{ needs.setup_env.outputs.branch_name }}-${{ env.GITHUB_RUN_ID }} ghcr.io/unbindapp/unbind-ui:${{ needs.setup_env.outputs.branch_name }}-${{ env.GITHUB_RUN_ID }}-amd64 | |
| docker manifest annotate --arch arm64 --os linux ghcr.io/unbindapp/unbind-ui:${{ needs.setup_env.outputs.branch_name }}-${{ env.GITHUB_RUN_ID }} ghcr.io/unbindapp/unbind-ui:${{ needs.setup_env.outputs.branch_name }}-${{ env.GITHUB_RUN_ID }}-arm64 | |
| docker manifest push ghcr.io/unbindapp/unbind-ui:${{ needs.setup_env.outputs.branch_name }}-${{ env.GITHUB_RUN_ID }} | |
| # Create latest tag for the branch | |
| docker manifest create ghcr.io/unbindapp/unbind-ui:latest \ | |
| --amend ghcr.io/unbindapp/unbind-ui:${{ needs.setup_env.outputs.branch_name }}-${{ env.GITHUB_RUN_ID }}-amd64 \ | |
| --amend ghcr.io/unbindapp/unbind-ui:${{ needs.setup_env.outputs.branch_name }}-${{ env.GITHUB_RUN_ID }}-arm64 | |
| docker manifest annotate --arch amd64 --os linux ghcr.io/unbindapp/unbind-ui:latest ghcr.io/unbindapp/unbind-ui:${{ needs.setup_env.outputs.branch_name }}-${{ env.GITHUB_RUN_ID }}-amd64 | |
| docker manifest annotate --arch arm64 --os linux ghcr.io/unbindapp/unbind-ui:latest ghcr.io/unbindapp/unbind-ui:${{ needs.setup_env.outputs.branch_name }}-${{ env.GITHUB_RUN_ID }}-arm64 | |
| docker manifest push ghcr.io/unbindapp/unbind-ui:latest |