Improve open-in-new icon #77
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 and Deploy to Cloudflare Pages | |
on: | |
# schedule: | |
# - cron: "0 15 * * *" | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
pull_request: | |
types: | |
- opened | |
- synchronize | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
permissions: | |
pull-requests: write | |
steps: | |
- name: Checkout repository | |
id: checkout_repo | |
uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.GH_PAT }} | |
- name: Build site | |
id: build_site | |
env: | |
COMMIT_HASH: ${{ github.sha }} | |
GOOGLE_SHEET_APP_URL: ${{ secrets.GOOGLE_SHEET_APP_URL }} | |
# PUBLIC_TURNSTILE_SITE_KEY: ${{ secrets.PUBLIC_TURNSTILE_SITE_KEY }} | |
run: | | |
npm install --legacy-peer-deps | |
npm run build | |
echo "result=built" >> $GITHUB_OUTPUT | |
- name: Extract variables | |
id: extract_vars | |
if: steps.build_site.outputs.result == 'built' | |
run: | # branch_trunc is the branch truncated to 28 chars, which is the CF deploy preview subdomain length | |
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | |
echo "datetime=$(date +'%Y-%m-%d %H:%M:%S')" >> $GITHUB_OUTPUT | |
branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}} | |
branch_trunc=${branch:0:28} | |
echo "branch=${branch}" >> $GITHUB_OUTPUT | |
echo "branch_trunc=${branch_trunc}" >> $GITHUB_OUTPUT | |
- name: Deploy to Cloudflare Pages | |
id: deploy | |
if: steps.build_site.outputs.result == 'built' | |
run: npx wrangler pages deploy --branch=${{ steps.extract_vars.outputs.branch }} | |
env: | |
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
- name: Add preview URL to pull request | |
if: github.event_name == 'pull_request' && steps.build_site.outputs.result == 'built' | |
uses: thollander/actions-comment-pull-request@v2 | |
with: | |
comment_tag: deploy_preview | |
mode: recreate | |
message: | | |
## Deployed to Cloudflare Pages! :rocket: | |
| Name | Result | | |
| ----------------------- | - | | |
| **Preview URL**: | https://${{ steps.extract_vars.outputs.branch_trunc }}.scripturesofthechosen.pages.dev | | |
| **Last commit:** | `${{ steps.extract_vars.outputs.sha_short }}` | | |
| **Deployed at**: | `${{ steps.extract_vars.outputs.datetime }}` | |