enh: Cloudflare Pages SSG publishing

This commit is contained in:
Ben Allfree
2023-09-30 20:39:27 -07:00
parent 05792508f4
commit 67b3e4faba
2 changed files with 48 additions and 19 deletions

View File

@@ -1,19 +0,0 @@
name: Node.js CI
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: yarn
- run: yarn lint

48
.github/workflows/publish.yaml vendored Normal file
View File

@@ -0,0 +1,48 @@
on: [push]
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
deployments: write
name: Publish to Cloudflare Pages
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: 20.x
- run: yarn install
- run: yarn lint
- run: yarn build
- name: Publish www to Cloudflare Pages
uses: cloudflare/pages-action@v1
id: www_deploy
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
projectName: pockethost
directory: ./packages/pockethost.io/build
branch: ${{ github.head_ref || github.ref_name }}
wranglerVersion: '3'
- name: Discord feature branch notification
if: github.ref_name != 'master'
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
uses: Ilshidur/action-discord@master
with:
args: '**PREVIEW** ${{ steps.www_deploy.outputs.url }} was generated from [commit ${{ github.sha }}](https://github.com/${{ github.repository}}/commit/${{ github.sha }}) on [${{ github.repository}}#${{ github.ref_name }}](https://github.com/${{ github.repository}}/tree/${{ github.ref_name }})'
- name: Discord live branch notification
if: github.ref_name == 'master'
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
uses: Ilshidur/action-discord@master
with:
args: '**LIVE** https://pockethost.io has been updated from [commit ${{ github.sha }}](https://github.com/${{ github.repository}}/commit/${{ github.sha }}) on [${{ github.repository}}#${{ github.ref_name }}](https://github.com/${{ github.repository}}/tree/${{ github.ref_name }})'