Delivery to preview #16
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: Delivery to preview | |
on: | |
push: | |
branches: [ main ] | |
paths: | |
- '.github/workflows/cd.preview.yml' | |
- '.vercelignore' | |
- '.babelrc' | |
- '.npmrc' | |
- '**.css' | |
- '**.jsx?' | |
- '**.tsx?' | |
- '*.json' | |
- '!docs/**/*' | |
- '!tools/**/*' | |
tags: [ '!*' ] | |
schedule: | |
- cron: 0 7 1 * * # at 07:00 on day-of-month 1, UTC | |
workflow_dispatch: | |
inputs: | |
reason: | |
description: The reason for dispatching it manually. | |
type: string | |
default: manual healthcheck | |
required: true | |
jobs: | |
deploy: | |
name: Deploying | |
runs-on: ubuntu-latest | |
environment: | |
name: vercel | |
url: ${{ steps.deployment.outputs.page_url }} | |
steps: | |
- name: Checkout the repository | |
uses: actions/checkout@v3 | |
with: { fetch-depth: 0 } | |
- name: Set up Node.js environment | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
cache: npm | |
cache-dependency-path: tools/package-lock.json | |
check-latest: true | |
- name: Install tools | |
run: ./Taskfile tools npm ci | |
- name: Build and deploy to Vercel | |
id: deployment | |
run: | | |
shopt -s expand_aliases | |
alias run=./Taskfile | |
run @token set vercel ${{ secrets.VERCEL_TOKEN }} | |
echo page_url=$(run @deploy) >> $GITHUB_OUTPUT | |
env: | |
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} | |
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} | |
notify: | |
name: Notifying | |
needs: [ deploy ] | |
runs-on: ubuntu-latest | |
if: failure() || success() | |
steps: | |
- name: Checkout the repository | |
uses: actions/checkout@v3 | |
with: { fetch-depth: 0 } | |
- name: Send notification | |
uses: ./.github/actions/notify | |
continue-on-error: true | |
with: | |
emoji: 👀 | |
channel: ${{ secrets.SLACK_WEBHOOK }} | |
success: ${{ ! contains(needs.*.result, 'failure') }} |