Deploy ICS Files to Cloudflare Workers #256
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: Deploy ICS Files to Cloudflare Workers | |
on: | |
workflow_dispatch: | |
inputs: | |
site: | |
type: choice | |
description: Which site? | |
options: | |
- f1 | |
- f2 | |
- f3 | |
- fe | |
- indycar | |
- motogp | |
- extremee | |
- f1-academy | |
workflow_call: | |
inputs: | |
site: | |
required: true | |
type: string | |
secrets: | |
CF_API_TOKEN: | |
required: true | |
CF_ZONE_ID: | |
required: true | |
CF_ACCOUNT_ID: | |
required: true | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
env: | |
SITE: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.site || inputs.site }} | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: actions/setup-node@v2 | |
with: | |
node-version: '22' | |
- name: Site Selection | |
run: | | |
echo "Selected Site: ${{ env.SITE }}" | |
- name: Cache node modules | |
uses: actions/cache@v2 | |
env: | |
cache-name: cache-node-modules | |
with: | |
# npm cache files are stored in `~/.npm` on Linux/macOS | |
path: ~/.npm | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-build-${{ env.cache-name }}- | |
${{ runner.os }}-build- | |
${{ runner.os }}- | |
- name: Install Dependencies | |
run: | | |
npm i wrangler | |
npm i ics | |
npm i dayjs | |
- name: Generate Specific Calendars | |
run: | | |
sudo node build/generate-calendars.js ${{env.SITE}} | |
- name: Publish to Cloudflare Workers Sites | |
run: | | |
mkdir -p ~/.wrangler/config/ | |
echo "api_token=\"${CF_API_TOKEN}\"" > ~/.wrangler/config/default.toml | |
yarn wrangler publish --env ${{env.SITE}} | |
env: | |
CLOUDFLARE_API_TOKEN: ${{ secrets.CF_API_TOKEN }} | |
CLOUDFLARE_ZONE_ID: ${{ secrets.CF_ZONE_ID }} | |
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CF_ACCOUNT_ID }} |