Update node Docker tag to v25 #112
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: "Plan building pnpm image" | |
| on: | |
| pull_request: | |
| paths: | |
| - 'images/**' | |
| jobs: | |
| find-changed-dirs: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| tags: ${{ steps.get-changes.outputs.tags }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Get changed directories | |
| id: get-changes | |
| run: | | |
| BEFORE_COMMIT=$(git rev-parse origin/main) | |
| CURRENT_COMMIT=${{ github.sha }} | |
| # Get the list of changed directories under the images folder | |
| CHANGED_DIRS=$(git diff --name-only "$BEFORE_COMMIT" "$CURRENT_COMMIT" \ | |
| | grep '^images/' \ | |
| | cut -d/ -f2 \ | |
| | sort \ | |
| | uniq) | |
| echo "Changed directories: $CHANGED_DIRS" | |
| EXISTING_DIRS=$(find images -mindepth 1 -maxdepth 1 -type d \ | |
| | cut -d/ -f2 \ | |
| | sort \ | |
| | uniq) | |
| FILTERED_DIRS=$(comm -12 <(echo "$CHANGED_DIRS") <(echo "$EXISTING_DIRS")) | |
| TAGS=$(printf '%s\n' "$FILTERED_DIRS" | jq -R . | jq -sc .) | |
| echo "tags=$TAGS" | |
| echo "tags=$TAGS" >> $GITHUB_OUTPUT | |
| comment-on-pr: | |
| runs-on: ubuntu-latest | |
| needs: find-changed-dirs | |
| permissions: | |
| contents: 'read' | |
| pull-requests: 'write' | |
| steps: | |
| - name: Comment on PR | |
| uses: actions/github-script@v8 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| script: | | |
| const tags = ${{ needs.find-changed-dirs.outputs.tags }}; | |
| if (tags.length === 0) { | |
| github.issues.createComment({ | |
| issue_number: context.issue.number, | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| body: 'No changes detected in the images directory.' | |
| }); | |
| } else { | |
| github.issues.createComment({ | |
| issue_number: context.issue.number, | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| body: `Following images will be built and pushed: \n${tags.map(tag => `- ${tag}`).join('\n')}` | |
| }); | |
| } | |
| build-test-images: | |
| needs: find-changed-dirs | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| tag: ${{ fromJson(needs.find-changed-dirs.outputs.tags) }} | |
| runner: ["ubuntu-24.04", "ubuntu-24.04-arm"] | |
| runs-on: ${{ matrix.runner }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| - name: Build Docker image | |
| run: | | |
| docker build -t pnpm-image:latest ./images/${{ matrix.tag }} | |
| - name: Building Sample Application | |
| run: | | |
| docker build -f ./sample-app/Dockerfile ./sample-app/next-app |