Update StatsLighthouse.astro #216
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: Cloudflare Pages Deployment | |
on: | |
push: | |
branches: | |
- main | |
- next | |
schedule: | |
- cron: "20 4 * * *" | |
workflow_dispatch: | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
name: Build and Deploy | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Deno | |
uses: denoland/setup-deno@v2 | |
with: | |
deno-version: v2.3.3 | |
- name: Install Dependencies | |
run: deno task install | |
- name: Get branch name | |
run: echo "BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)" >> $GITHUB_ENV | |
- name: Set environment variables | |
run: | | |
if [ "${{ env.BRANCH_NAME }}" = "main" ]; then | |
echo "PRODUCTION_BUILD=true" >> $GITHUB_ENV | |
fi | |
- name: Build Website | |
env: | |
CF_ZONE_ID: ${{ secrets.CF_ZONE_ID }} | |
CF_RADAR_TOKEN: ${{ secrets.CF_RADAR_TOKEN }} | |
GOOGLE_PAGESPEED_KEY: ${{ secrets.GOOGLE_PAGESPEED_KEY }} | |
PRODUCTION_BUILD: ${{ env.PRODUCTION_BUILD }} | |
run: deno task build | |
- name: Create robots.txt for non-production builds | |
if: env.BRANCH_NAME != 'main' | |
run: | | |
echo "User-agent: *" > ./dist/robots.txt | |
echo "Disallow: /" >> ./dist/robots.txt | |
echo "robots.txt created successfully for non-production branch." | |
- name: Install Wrangler | |
run: deno install --global --allow-scripts npm:wrangler@latest | |
- name: Deploy Website to Cloudflare | |
uses: cloudflare/wrangler-action@v3 | |
with: | |
accountId: ${{ secrets.CF_ACCOUNT_ID }} | |
apiToken: ${{ secrets.CF_DEPLOY_TOKEN }} | |
command: pages deploy ./dist --project-name=stupid --branch=${{ env.BRANCH_NAME }} --commit-dirty=true |