Skip to content

Commit

Permalink
chore: cloudflare (#865)
Browse files Browse the repository at this point in the history
  • Loading branch information
huntabyte authored Mar 6, 2024
1 parent 434dd12 commit 4b4f691
Show file tree
Hide file tree
Showing 5 changed files with 155 additions and 304 deletions.
76 changes: 76 additions & 0 deletions .github/workflows/docs-preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#################### 🚧 WARNING: READ THIS BEFORE USING THIS FILE 🚧 ####################
#
#
#
# IF YOU DON'T KNOW WHAT YOU'RE DOING, YOU CAN EASILY LEAK SECRETS BY USING A
# `pull_request_target` WORKFLOW INSTEAD OF `pull_request`! SERIOUSLY, DO NOT
# BLINDLY COPY AND PASTE THIS FILE WITHOUT UNDERSTANDING THE FULL IMPLICATIONS
# OF WHAT YOU'RE DOING! WE HAVE TESTED THIS FOR OUR OWN USE CASES, WHICH ARE
# NOT NECESSARILY THE SAME AS YOURS! WHILE WE AREN'T EXPOSING ANY OF OUR SECRETS,
# ONE COULD EASILY DO SO BY MODIFYING OR ADDING A STEP TO THIS WORKFLOW!
#
#
#
#################### 🚧 WARNING: READ THIS BEFORE USING THIS FILE 🚧 ####################

name: Docs - Preview Deployment
on:
pull_request_target:
paths:
- apps/www/**

# cancel in-progress runs on new commits to same PR (github.event.number)
concurrency:
group: ${{ github.workflow }}-${{ github.event.number || github.sha }}
cancel-in-progress: true

jobs:
deploy-preview:
permissions:
contents: read
pull-requests: write
deployments: write
runs-on: ubuntu-latest
name: Deploy Preview to Cloudflare Pages (admin)
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
- uses: pnpm/action-setup@v2
with:
version: 8
- uses: actions/setup-node@v3
with:
node-version: 20

# PNPM Store cache setup
- name: Get pnpm store directory
id: pnpm-cache
run: |
echo "pnpm_cache_dir=$(pnpm store path)" >> $GITHUB_OUTPUT
- name: Setup pnpm cache
uses: actions/cache@v3
with:
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install

- name: Build site
run: pnpm build

- name: Deploy to Cloudflare Pages
id: cloudflare-pages-deploy
uses: AdrianGonz97/refined-cf-pages-action@v1
with:
apiToken: ${{ secrets.CF_API_TOKEN }}
accountId: ${{ secrets.CF_ACCOUNT_ID }}
githubToken: ${{ secrets.GITHUB_TOKEN }}
projectName: shadcn-svelte
directory: ./.svelte-kit/cloudflare
workingDirectory: apps/www
deploymentName: Preview
55 changes: 55 additions & 0 deletions .github/workflows/docs-production.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Docs Production Deployment
on:
push:
branches:
- main
paths:
- apps/www/**

concurrency: ${{ github.workflow }}-${{ github.ref }}

jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
deployments: write
name: Publish to Cloudflare Pages
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2
with:
version: 8
- uses: actions/setup-node@v3
with:
node-version: 20

# PNPM Store cache setup
- name: Get pnpm store directory
id: pnpm-cache
run: |
echo "pnpm_cache_dir=$(pnpm store path)" >> $GITHUB_OUTPUT
- name: Setup pnpm cache
uses: actions/cache@v3
with:
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install

- name: Build site
run: pnpm build

- name: Deploy to Cloudflare Pages
uses: AdrianGonz97/refined-cf-pages-action@v1
with:
apiToken: ${{ secrets.CF_API_TOKEN }}
accountId: ${{ secrets.CF_ACCOUNT_ID }}
githubToken: ${{ secrets.GITHUB_TOKEN }}
projectName: shadcn-svelte
directory: ./.svelte-kit/cloudflare
workingDirectory: apps/www
deploymentName: Production
2 changes: 1 addition & 1 deletion apps/www/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"@faker-js/faker": "^8.0.2",
"@playwright/test": "^1.36.2",
"@prettier/sync": "0.3.0",
"@sveltejs/adapter-vercel": "^3.0.3",
"@sveltejs/adapter-cloudflare": "2.3.4",
"@sveltejs/kit": "^1.27.1",
"@types/d3-scale": "^4.0.6",
"@types/hast": "^3.0.4",
Expand Down
Loading

0 comments on commit 4b4f691

Please sign in to comment.