build(deps-dev): bump @types/node from 22.12.0 to 22.13.0 #143
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: Cloudflare Pages Deploy | |
env: | |
ARTIFACT_NAME: blog-artifact | |
on: | |
push: | |
branches: ["main"] | |
pull_request: | |
branches: ["main"] | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
name: Build Pages | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "20" | |
cache: npm | |
- name: Restore cache | |
uses: actions/cache@v4 | |
with: | |
path: | | |
.next/cache | |
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx', '**.md') }} | |
restore-keys: | | |
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}- | |
- name: Install dependencies | |
run: npm ci | |
- name: Build with Next.js | |
run: npm run build | |
- name: Upload artifact | |
if: github.event.pull_request.head.repo.fork == false | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ env.ARTIFACT_NAME }} | |
retention-days: 3 | |
path: ./out | |
- name: Skip | |
if: github.event.pull_request.head.repo.fork == true | |
run: echo "Skipping build for forked PR" | |
deploy: | |
runs-on: ubuntu-latest | |
needs: build | |
name: Deploy to Cloudflare Pages | |
permissions: | |
contents: read | |
deployments: write | |
pull-requests: write # To can create a comment in PR | |
steps: | |
- name: Checkout | |
if: github.event.pull_request.head.repo.fork == false | |
uses: actions/checkout@v4 | |
- name: Download a Build Artifact | |
if: github.event.pull_request.head.repo.fork == false | |
uses: actions/download-artifact@v4 | |
with: | |
name: ${{ env.ARTIFACT_NAME }} | |
path: ./out | |
- name: Deploy | |
id: deploy | |
if: github.event.pull_request.head.repo.fork == false | |
uses: cloudflare/wrangler-action@v3 | |
with: | |
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
command: pages deploy out --project-name=blog-c3 --branch ${{ github.ref_name }} | |
gitHubToken: ${{ secrets.GITHUB_TOKEN }} | |
- name: Comment PR | |
if: github.event.pull_request.head.repo.fork == false | |
uses: actions/github-script@v7.0.1 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
const { issue: { number: issue_number }, repo: { owner, repo } } = context; | |
const message = `### 🚀 **Preview Url** 🚀 | |
[${{ steps.deploy.outputs.deployment-url }}](${{ steps.deploy.outputs.deployment-url }})`; | |
github.rest.issues.createComment({ | |
issue_number, | |
owner, | |
repo, | |
body: message | |
}); | |
- name: Skip | |
if: github.event.pull_request.head.repo.fork == true | |
run: echo "Skipping deploy for forked PR" |