Update nextjs monorepo to v15.1.6 #3769
Workflow file for this run
This file contains 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, test, and deploy | |
on: | |
push: | |
pull_request: | |
schedule: | |
# Run once per week to ensure that the pipeline is okay. | |
- cron: "23 13 * * 0" | |
permissions: | |
contents: read | |
env: | |
ARTIFACT_NAME: jdkcomparison-site | |
# Use Node.js LTS. Schedule: https://nodejs.org/en/about/releases/ | |
NODE_VERSION: 22.x | |
jobs: | |
common-checks: | |
name: Run common checks | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Run shellcheck on shell scripts | |
run: find . -name node_modules -prune -o -type f -name "*.sh" -exec shellcheck {} \; | |
- name: Run Prettier to ensure files are properly formatted | |
run: npx prettier@`node -p -e "require('./package.json').devDependencies['prettier']"` --check . | |
build: | |
name: Build and test | |
runs-on: ubuntu-latest | |
needs: | |
- common-checks | |
permissions: | |
contents: read | |
checks: write | |
pull-requests: write | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Use Node.js ${{ env.NODE_VERSION }} | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ env.NODE_VERSION }} | |
cache: "npm" | |
- name: Install dependencies | |
run: npm install | |
- name: Install Playwright Browsers | |
run: npx playwright install --with-deps | |
- name: Lint | |
run: npm run lint | |
- name: Run unit tests | |
run: npm run jest | |
# Starts the Next.js development server and puts it into the background before running the tests. Afterwards, the | |
# development server is stopped. | |
- name: Run E2E tests | |
run: | | |
npm run dev > /dev/null 2>&1 & | |
PID=$! | |
npm run e2e | |
kill "$PID" | |
- name: Build | |
run: npx @cloudflare/next-on-pages@`node -p -e "require('./package.json').devDependencies['@cloudflare/next-on-pages']"` | |
# Upload build output before anything can alter it. | |
- name: Upload artifact for deployment job | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ env.ARTIFACT_NAME }} | |
path: .vercel/output/static | |
- name: Publish Test Results | |
uses: EnricoMi/publish-unit-test-result-action@v2 | |
if: always() | |
with: | |
check_name: Test Results of Node.js ${{ env.NODE_VERSION }} | |
files: | | |
build/reports/*.xml | |
deploy-preview: | |
name: Deploy preview | |
runs-on: ubuntu-latest | |
needs: | |
- build | |
permissions: | |
contents: read | |
deployments: write | |
pull-requests: write | |
outputs: | |
preview-url: ${{ steps.cloudflare-deployment.outputs.deployment-url }} | |
steps: | |
- name: Set PREVIEW_NAME for main branch | |
if: github.ref == 'refs/heads/main' | |
run: | | |
echo "PREVIEW_NAME=main-preview" >> $GITHUB_ENV | |
- name: Set PREVIEW_NAME for all branches other than main | |
if: github.ref != 'refs/heads/main' | |
run: | | |
echo "PREVIEW_NAME=${{ github.ref_name }}" >> $GITHUB_ENV | |
- name: Download artifact from build job | |
uses: actions/download-artifact@v4 | |
with: | |
name: ${{ env.ARTIFACT_NAME }} | |
path: site | |
- name: Publish to Cloudflare Pages | |
id: cloudflare-deployment | |
uses: cloudflare/wrangler-action@v3 | |
with: | |
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
command: pages deploy site --project-name=jdkcomparison --branch=${{ env.PREVIEW_NAME }} | |
- uses: mshick/add-pr-comment@v2 | |
with: | |
message: | | |
### <span aria-hidden="true">✅</span> Your deployment is ready! | |
| Name | Link | | |
|-|-| | |
|Deployed Commit | ${{ github.sha }} | | |
|Workflow Log | ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} | | |
|Preview URL | ${{ steps.cloudflare-deployment.outputs.deployment-url }} | | |
--- | |
acceptance: | |
name: Run acceptance tests | |
runs-on: ubuntu-latest | |
needs: | |
- build | |
- deploy-preview | |
permissions: | |
contents: read | |
checks: write | |
pull-requests: write | |
env: | |
PLAYWRIGHT_BASE_URL: ${{ needs.deploy-preview.outputs.preview-url }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Use Node.js ${{ env.NODE_VERSION }} | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ env.NODE_VERSION }} | |
cache: "npm" | |
- name: Install dependencies | |
run: npm install | |
- name: Install Playwright Browsers | |
run: npx playwright install --with-deps | |
- name: Run acceptance tests | |
run: | | |
echo "Run acceptance tests against ${{ env.PLAYWRIGHT_BASE_URL }}" | |
npm run acceptance | |
deploy-to-production: | |
name: Deploy to production | |
if: github.ref == 'refs/heads/main' | |
runs-on: ubuntu-latest | |
needs: | |
- build | |
- acceptance | |
permissions: | |
contents: read | |
deployments: write | |
pull-requests: write | |
steps: | |
- name: Download artifact from build job | |
uses: actions/download-artifact@v4 | |
with: | |
name: ${{ env.ARTIFACT_NAME }} | |
path: site | |
- name: Publish to Cloudflare Pages | |
id: cloudflare-deployment | |
uses: cloudflare/wrangler-action@v3 | |
with: | |
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
command: pages deploy site --project-name=jdkcomparison --branch=${{ github.ref_name }} |