Skip to content

Commit

Permalink
Merge pull request #179 from davwheat/cf-pages
Browse files Browse the repository at this point in the history
feat: migrate to Cloudflare Pages
  • Loading branch information
davwheat authored Apr 8, 2024
2 parents 845a907 + 7df18b8 commit cf2a367
Show file tree
Hide file tree
Showing 40,190 changed files with 2,649 additions and 4,754 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
159 changes: 90 additions & 69 deletions .github/workflows/smoketest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,72 +2,75 @@ name: Smoketest

on:
push:
branches:
- main
- deploy
pull_request:
workflow_dispatch:

env:
NODE_VERSION: 20.x
CF_PAGES_PROJECT_NAME: rail-announcements

jobs:
formatting:
smoketest:
runs-on: ubuntu-latest
name: Verify formatting
name: Test, build and deploy

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v4
- name: Find existing build status comment
continue-on-error: true
uses: peter-evans/find-comment@v3
if: github.event_name == 'pull_request'
id: find_status_comment
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'yarn'

- name: Install dependencies
run: |
yarn install --immutable
- name: Verify formatting
run: yarn format:check

build:
name: Build site
runs-on: ubuntu-latest
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: Deploying with

needs: [formatting]

steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Create or update comment
continue-on-error: true
uses: peter-evans/create-or-update-comment@v4
if: github.event_name == 'pull_request'
with:
persist-credentials: false
fetch-depth: 0
issue-number: ${{ github.event.pull_request.number }}
comment-id: ${{ steps.find_status_comment.outputs.comment-id }}
edit-mode: replace
body: |
## Deploying with &nbsp;<a href="https://pages.dev"><img alt="Cloudflare Pages" src="https://user-images.githubusercontent.com/23264/106598434-9e719e00-654f-11eb-9e59-6167043cfa01.png" width="16"></a> &nbsp;Cloudflare Pages
<table><tr><td><strong>Latest commit:</strong> </td><td>
<code>${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}</code>
</td></tr>
<tr><td><strong>Status:</strong></td><td>
&nbsp;⚡️&nbsp; Build in progress...
</td></tr>
</table>
- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'yarn'

- name: Setup Pages
id: pages
uses: actions/configure-pages@v4
if: github.ref == 'refs/heads/deploy' && github.event_name == 'push'
with:
static_site_generator: gatsby

- name: Install dependencies
run: |
yarn install --immutable
- name: Verify formatting
run: yarn format:check

- name: Restore Gatsby cache
uses: actions/cache@v3
uses: actions/cache@v4
id: gatsbyCache
with:
path: ./.cache
key: ${{ runner.os }}-gatsby-cache-${{ hashFiles('public') }}
key: ${{ runner.os }}-gatsby-cache-${{ secrets.CACHE_VERSION }}-${{ hashFiles('public') }}
restore-keys: |
${{ runner.os }}-gatsby-cache-
${{ runner.os }}-gatsby-cache-${{ secrets.CACHE_VERSION }}-
- name: Build site
run: yarn build:ci
Expand All @@ -88,48 +91,66 @@ jobs:
yarn sentry-cli --url https://sentry.service.davw.network releases set-commits "$VERSION" --auto
yarn sentry-cli --url https://sentry.service.davw.network releases finalize "$VERSION"
- name: Upload artifact
uses: actions/upload-pages-artifact@v2
- name: Run D1 migrations
uses: cloudflare/wrangler-action@v3
with:
path: ./public

# Deploy job
deploy:
# Add a dependency to the build job
needs: build

if: github.ref == 'refs/heads/deploy' && github.event_name == 'push'

# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source
actions: read
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
command: d1 migrations apply rail-announcements

# Deploy to the github-pages environment
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

# Specify runner + deployment step
runs-on: ubuntu-latest

steps:
- name: Setup Rclone
uses: AnimMouse/setup-rclone@v1
with:
rclone_config: ${{ secrets.RCLONE_CONFIG }}

- name: Checkout code
uses: actions/checkout@v4
with:
persist-credentials: false
fetch-depth: 0

- run: rclone copy dest:destpath
- name: Upload audio files to Cloudflare R2
run: |
rclone --fast-list -v --transfers=128 --checkers=256 --progress sync "./audio" "Cloudflare R2:/rail-announcements-audio"
env:
RCLONE_CONFIG_PASS: ${{ secrets.RCLONE_CONFIG_PASSWORD }}

- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v3
- name: Publish to Cloudflare Pages
uses: cloudflare/pages-action@1
id: cf-pages-upload
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
projectName: ${{ env.CF_PAGES_PROJECT_NAME }}
directory: public # e.g. 'dist'
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
wranglerVersion: '3'
# Use PR head branch if available, otherwise use the current branch
branch: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref || github.ref_name }}

- name: Find existing build status comment
continue-on-error: true
uses: peter-evans/find-comment@v3
if: github.event_name == 'pull_request'
id: find_current_status_comment
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}

- name: Update comment
continue-on-error: true
if: github.event_name == 'pull_request' && steps.find_current_status_comment.outputs.comment-id != ''
uses: peter-evans/create-or-update-comment@v4
with:
comment-id: ${{ steps.find_current_status_comment.outputs.comment-id }}
edit-mode: replace
body: |
## Deploying with &nbsp;<a href="https://pages.dev"><img alt="Cloudflare Pages" src="https://user-images.githubusercontent.com/23264/106598434-9e719e00-654f-11eb-9e59-6167043cfa01.png" width="16"></a> &nbsp;Cloudflare Pages
<table><tr><td><strong>Latest commit:</strong> </td><td>
<code>${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}</code>
</td></tr>
<tr><td><strong>Status:</strong></td><td>
&nbsp;✅&nbsp; Deploy successful!
</td></tr>
<tr><td><strong>Preview URL:</strong></td><td>
<a href='${{ steps.cf-pages-upload.outputs.url }}'>${{ steps.cf-pages-upload.outputs.url }}</a>
</td></tr>
<tr><td><strong>Branch Preview URL:</strong></td><td>
<a href='${{ steps.cf-pages-upload.outputs.alias }}'>${{ steps.cf-pages-upload.outputs.alias }}</a>
</td></tr>
</table>
71 changes: 0 additions & 71 deletions .github/workflows/worker-deploy.yml

This file was deleted.

3 changes: 1 addition & 2 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
.cache
package.json
package-lock.json
public
size-plugin.json
cf-workers/.wrangler
functions/.wrangler
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# UK Railway Announcements

[View the website!](https://rail-announcements.davwheat.dev/)
[View the website!](https://railannouncements.co.uk/)

A website to generate and play UK railway announcements.

> **Info**
>
> Due to a legal notice by Worldline IT Services UK Limited, Atos Anne's audio recordings are no longer available.
>
> For more information, please visit https://rail-announcements.davwheat.dev/atos-worldline
> For more information, please visit https://railannouncements.co.uk/atos-worldline
## Introduction

Expand All @@ -21,7 +21,7 @@ I decided I'll do it proactively this time!
### Audio contributions

The folder for audio files can be found at `static/audio/`.
The folder for audio files can be found at `audio/`.

- Open a separate pull request for each announcement system you're modifying.
- Audio files should be split wherever possible, but don't overdo it.
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit cf2a367

Please sign in to comment.