Skip to content

Feature/rise from your grave #71

Feature/rise from your grave

Feature/rise from your grave #71

Workflow file for this run

name: Continuous Deployment
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
jobs:
# borrowed from: https://github.saobby.my.eu.orgmunity/t/dont-run-actions-on-draft-pull-requests/16817/20
fail_if_pull_request_is_draft:
if: github.event.pull_request.draft == true
runs-on: ubuntu-latest
steps:
- name: Fail in order to indicate that Pull Request needs to be marked as Ready for Review before CI/CD pipeline can run.
run: exit 1
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.GH_AUTH_TOKEN }}
- name: Configure git
run: |
git config --global user.email "bot@workwithme.app"
git config --global user.name "Work w/ Me Release Bot"
- uses: actions/setup-node@v4
with:
node-version: 14
cache: 'npm'
cache-dependency-path: package-lock.json
# - name: Cache node modules
# uses: actions/cache@v4
# env:
# cache-name: cache-node-modules
# with:
# 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
# HACK: npm ci was failing, probably due to some old dependency in this now-ancient project
run: npm install
- name: Encode Supabase API Key
id: credentials
run: |
api_key="${{ secrets.SUPABASE_ANON_KEY }}"
url_encoded_key=$(node -p "encodeURIComponent('$api_key')")
echo "ENCODED_SUPABASE_ANON_KEY=${url_encoded_key}" >> $GITHUB_OUTPUT
- name: Generate Types
run: npm run build:types
env:
SUPABASE_PROJECT_ID: ${{ secrets.SUPABASE_PROJECT_ID }}
SUPABASE_ANON_KEY: ${{ steps.credentials.outputs.ENCODED_SUPABASE_ANON_KEY }}
- name: Check for modified files
id: git-check
run:
value=$(if [ -n "$(git status --porcelain)" ]; then echo "true"; else echo "false"; fi)
echo "modified=$value" >> $GITHUB_OUTPUT
- name: Run Tests
run: npm test
# - name: PR Preview Deployment
# uses: amondnet/vercel-action@v20
# id: vercel-action-pr
# if: startsWith(github.head_ref, 'feature/') && github.base_ref == 'main'
# with:
# vercel-project-name: work-with-me
# vercel-token: ${{ secrets.VERCEL_TOKEN }}
# github-token: ${{ secrets.GH_AUTH_TOKEN }}
# vercel-org-id: ${{ secrets.VERCEL_ORG_ID}}
# vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID}}
# scope: interweb-alchemy
# alias-domains: |
# pr-{{PR_NUMBER}}-work-with-me.vercel.app
- name: Deploy to Production
uses: amondnet/vercel-action@v20
id: vercel-action-production
if: github.ref == 'refs/heads/main'
with:
vercel-project-name: work-with-me
vercel-token: ${{ secrets.VERCEL_TOKEN }}
github-token: ${{ secrets.GH_AUTH_TOKEN }}
vercel-org-id: ${{ secrets.VERCEL_ORG_ID}}
vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID}}
vercel-args: '--prod'
scope: interweb-alchemy
alias-domains: |
work-with-me.vercel.app
- name: Push Changes to Type Definitions
if: steps.git-check.outputs.modified == 'true'
run: |
git add .
git commit -m 'chore(types): update supabase type definitions'
git push origin HEAD:main
- name: Semantic Release
if: github.ref == 'refs/heads/main'
uses: cycjimmy/semantic-release-action@v2
with:
semantic_version: 18
extra_plugins: |
@semantic-release/git
env:
GITHUB_TOKEN: ${{ secrets.GH_AUTH_TOKEN }}