2023-10-02 14:46:33 -07:00

64 lines
2.6 KiB
YAML

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/www/_site
branch: ${{ github.head_ref || github.ref_name }}
wranglerVersion: '3'
- name: Publish dashboard to Cloudflare Pages
uses: cloudflare/pages-action@v1
id: dashboard_deploy
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
projectName: pockethost-dashboard
directory: ./packages/dashboard/build
branch: ${{ github.head_ref || github.ref_name }}
wranglerVersion: '3'
- name: Add SHORT_SHA env property with commit short sha
run: echo "SHORT_SHA=`echo ${GITHUB_SHA} | cut -c1-8`" >> $GITHUB_ENV
- 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 }} and ${{ steps.dashboard_deploy.outputs.url }} were generated from [${SHORT_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 ([permalink](${{ steps.www_deploy.outputs.url }})) and https://app.pockethost.io ([permalink](${{ steps.dashboard_deploy.outputs.url }})) were updated from [${SHORT_SHA}](https://github.com/${{ github.repository}}/commit/${{ github.sha }}) on [${{ github.repository}}#${{ github.ref_name }}](https://github.com/${{ github.repository}}/tree/${{ github.ref_name }})'