rss-reader/.github/workflows/main.yml

138 lines
3.8 KiB
YAML

on:
push:
branches:
main
env:
NODE_VERSION: 20
jobs:
setup:
runs-on: ubuntu-latest
name: Setup
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
id: node-setup
with:
node-version: ${{ env.NODE_VERSION }}
- uses: actions/cache@v4
id: cache-restore
with:
path: |
.yarn
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}-${{ env.NODE_VERSION }}
- name: Install dependencies
if: steps.cache-restore.outputs.cache-hit != 'true'
run: . script/bootstrap.sh
lint:
runs-on: ubuntu-latest
name: Lint
needs: setup
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
id: node-setup
with:
node-version: ${{ env.NODE_VERSION }}
- name: Yarn cache
uses: actions/cache@v4
id: yarn-cache-restore
with:
path: |
.yarn
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}-${{ env.NODE_VERSION }}
- name: Lint
run: |
. script/bootstrap.sh
yarn lint
typecheck:
runs-on: ubuntu-latest
name: Typecheck
needs: setup
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
id: node-setup
with:
node-version: ${{ env.NODE_VERSION }}
- name: Yarn cache
uses: actions/cache@v4
id: yarn-cache-restore
with:
path: |
.yarn
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}-${{ env.NODE_VERSION }}
- name: Lint
run: |
. script/bootstrap.sh
yarn typecheck
build-app:
runs-on: ubuntu-latest
name: Build App
needs: [typecheck, lint]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
id: node-setup
with:
node-version: ${{ env.NODE_VERSION }}
- name: Yarn cache
uses: actions/cache@v4
id: yarn-cache-restore
with:
path: |
.yarn
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}-${{ env.NODE_VERSION }}
- run: |
. script/bootstrap.sh
yarn build
- name: Build Artifacts
uses: actions/upload-artifact@v4
with:
name: build-artifacts
path: dist
deploy-frontend:
runs-on: ubuntu-latest
name: Deploy frontend
needs: build-app
steps:
- uses: actions/checkout@v4
- name: Yarn cache
uses: actions/cache@v4
id: yarn-cache-restore
with:
path: |
.yarn
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}-${{ env.NODE_VERSION }}
- run: corepack enable
- name: Build Artifacts
uses: actions/download-artifact@v4
with:
name: build-artifacts
path: dist
- uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
command: pages deploy --project-name=rss-reader ./dist
deploy-functions:
runs-on: ubuntu-latest
name: Deploy functions
needs: build-app
steps:
- uses: actions/checkout@v4
- name: Yarn cache
uses: actions/cache@v4
id: yarn-cache-restore
with:
path: |
.yarn
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}-${{ env.NODE_VERSION }}
- run: |
. script/bootstrap.sh
- uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
command: deploy --name=rss-reader-proxy --minify ./functions/rss-proxy/rss-proxy-cloudflare.mts