CI/CD #469
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
# GitHub Actions workflow | |
# https://help.github.com/actions | |
name: CI/CD | |
on: | |
push: | |
branches: [main] | |
tags: | |
- "v*" | |
pull_request: | |
branches: [main] | |
schedule: | |
- cron: "0 7 * * *" | |
workflow_dispatch: | |
inputs: | |
environment: | |
description: "Environment" | |
type: environment | |
default: "test" | |
required: true | |
env: | |
NODE_VERSION: 20.5.x | |
VERSION: ${{ github.event.pull_request.number }} | |
HUSKY: 0 | |
jobs: | |
build: | |
name: "Build" | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
# Configure Node.js and install NPM dependencies | |
- uses: actions/setup-node@v4 | |
with: { node-version: "${{ env.NODE_VERSION }}", cache: "yarn" } | |
- run: yarn install | |
# Analyze code for potential problems | |
- run: yarn prettier --check . | |
if: ${{ github.event_name == 'pull_request' }} | |
- run: yarn lint | |
if: ${{ github.event_name == 'pull_request' }} | |
- run: yarn tsc --build | |
- run: yarn workspace app test | |
if: ${{ github.event_name == 'pull_request' }} | |
# - run: yarn workspace edge test | |
# if: ${{ github.event_name == 'pull_request' }} | |
# Compile and save build artifacts | |
- run: yarn build | |
- uses: actions/upload-artifact@v4 | |
with: { name: "build", path: "app/dist\nedge/dist\n" } | |
deploy: | |
name: "Deploy" | |
runs-on: ubuntu-latest | |
needs: [build] | |
environment: | |
name: ${{ inputs.environment || 'test' }} | |
url: ${{ inputs.environment == 'prod' && 'https://example.com' || format('https://{0}.example.com', inputs.environment || 'test') }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: { node-version: "${{ env.NODE_VERSION }}", cache: "yarn" } | |
- run: yarn install | |
- uses: actions/download-artifact@v4 | |
with: { name: "build" } | |
- run: yarn workspace edge deploy --env=${{ inputs.environment || 'test' }} | |
if: ${{ false }} |