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

194 lines
5.5 KiB
YAML
Raw Normal View History

on:
push:
branches:
2021-07-17 16:35:10 +00:00
main
pull_request:
env:
2024-02-15 18:13:21 +00:00
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
2024-02-15 18:33:12 +00:00
yarn build
- name: Build Artifacts
uses: actions/upload-artifact@v4
with:
name: build-artifacts
2024-02-15 18:33:12 +00:00
path: 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
preview:
runs-on: ubuntu-latest
name: Deploy preview
2021-07-17 16:46:15 +00:00
if: ${{ github.ref != 'refs/heads/main' }}
needs: build-app
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
- name: Build Artifacts
uses: actions/download-artifact@v4
with:
name: build-artifacts
2024-02-15 18:33:12 +00:00
path: dist
- name: Deploy
id: preview-deploy
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
run: |
2024-02-15 18:33:12 +00:00
yarn netlify deploy --dir=dist --json | jq .deploy_url > output.log
echo "::set-output name=draft-url::$(cat output.log)"
- name: Report
uses: actions/github-script@v7
env:
DRAFT_URL: ${{ steps.preview-deploy.outputs.draft-url }}
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `:eyes: Branch deployed at ${process.env.DRAFT_URL}`
})
deploy:
runs-on: ubuntu-latest
name: Deploy
needs: build-app
2021-07-17 16:46:15 +00:00
if: ${{ github.ref == 'refs/heads/main' }}
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
- name: Build Artifacts
uses: actions/download-artifact@v4
with:
name: build-artifacts
2024-02-15 18:33:12 +00:00
path: dist
- name: Netlify CLI setup
run: npm install -g netlify-cli
- name: Deploy
id: preview-deploy
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
run: |
2024-02-15 18:33:12 +00:00
yarn netlify deploy --dir=dist --prod