Rebuild sample #11
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: Rebuild sample | |
| on: | |
| schedule: | |
| - cron: 0 0 * * 2 | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| jobs: | |
| build: | |
| permissions: | |
| contents: write # for peter-evans/create-pull-request to create branch | |
| pull-requests: write # for peter-evans/create-pull-request to create a PR | |
| name: Rebuild | |
| if: github.repository == 'CrowdStrike/foundry-sample-foundryjs-demo' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0 | |
| with: | |
| node-version: 22 | |
| - name: Install pnpm | |
| uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4.2.0 | |
| with: | |
| version: 10 | |
| - name: Get pnpm store directory | |
| shell: bash | |
| run: | | |
| echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | |
| - name: Setup pnpm cache | |
| uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3 | |
| with: | |
| path: ${{ env.STORE_PATH }} | |
| key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pnpm-store- | |
| - name: Check if rebuild needed | |
| id: check | |
| run: | | |
| LAST_BUILD=$(git log -1 --format=%H -- ui/pages/foundryjs-demo/src/dist/) | |
| if [ -z "$LAST_BUILD" ]; then | |
| echo "skip=false" >> "$GITHUB_OUTPUT" | |
| echo "No previous build found, rebuilding" | |
| exit 0 | |
| fi | |
| CHANGES=$(git diff --name-only "$LAST_BUILD" HEAD -- ui/pages/foundryjs-demo/package.json ui/pages/foundryjs-demo/pnpm-lock.yaml) | |
| if [ -z "$CHANGES" ]; then | |
| echo "skip=true" >> "$GITHUB_OUTPUT" | |
| echo "No dependency changes since last build, skipping" | |
| else | |
| echo "skip=false" >> "$GITHUB_OUTPUT" | |
| echo "Dependency changes detected:" | |
| echo "$CHANGES" | |
| fi | |
| - name: Install dependencies | |
| if: steps.check.outputs.skip != 'true' | |
| run: pnpm install --frozen-lockfile | |
| working-directory: ui/pages/foundryjs-demo | |
| - name: Build React app | |
| if: steps.check.outputs.skip != 'true' | |
| run: pnpm build | |
| working-directory: ui/pages/foundryjs-demo | |
| - name: Create commit | |
| if: steps.check.outputs.skip != 'true' | |
| run: | | |
| git add . | |
| git commit -a -m "Rebuild with latest dependencies" || true | |
| - name: Create Pull Request | |
| if: steps.check.outputs.skip != 'true' | |
| uses: peter-evans/create-pull-request@22a9089034f40e5a961c8808d113e2c98fb63676 # v7.0.11 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| commit-message: 'Rebuild with latest dependencies' | |
| title: 'Rebuild with latest dependencies' | |
| body: Weekly build with latest dependencies. | |
| labels: 'dependencies' |