Simplify profile auth & signature flow #1908
Workflow file for this run
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
# See: https://vercel.com/guides/how-to-alias-a-preview-deployment-using-the-cli | |
name: Deploy Carbonmark API | |
env: | |
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} | |
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID_CARBONMARK_API }} | |
on: | |
pull_request: | |
paths: | |
- "carbonmark-api/**" | |
jobs: | |
# Confirm that any changes to soruce code are accompanied by a version bump | |
check-version-update: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.ref }} | |
fetch-depth: 0 # We need this for fetching tags | |
- name: Check version update | |
run: | | |
VERSION_CHANGED=$(git diff origin/${{ github.base_ref }} HEAD -- 'carbonmark-api/package.json' | grep '"version":') | |
if [ -z "$VERSION_CHANGED" ]; then | |
echo "You must update the version line in package.json when changing files in your-directory" | |
exit 1 | |
fi | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Pull Vercel Environment Information | |
run: vercel env pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }} carbonmark-api/.env.local | |
- name: Run tests | |
run: | | |
cd carbonmark-api | |
npm install | |
npm run test | |
deploy_preview: | |
runs-on: ubuntu-latest | |
environment: Preview – carbonmark-api | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set short commit hash to environment variable | |
run: echo "SHORT_COMMIT_SHA=$(echo ${{ github.event.pull_request.head.sha }} | cut -c 1-7)" >> $GITHUB_ENV | |
- name: Pull Environment Vars | |
run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }} | |
- name: Build API | |
run: vercel build --token=${{ secrets.VERCEL_TOKEN }} | |
- name: Deploy to Vercel | |
run: | | |
url="$(vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }})" | |
echo "DEPLOYED_URL=$url" >> $GITHUB_ENV | |
- name: Healthcheck deployment | |
run: npx newman run carbonmark-api/postman_collection.json --env-var "url=${{ env.DEPLOYED_URL }}" | |
- name: Alias deployment | |
run: vercel alias --token=${{ secrets.VERCEL_TOKEN }} --scope=${{ secrets.VERCEL_TEAM_ID }} set "${{ env.DEPLOYED_URL }}" carbonmark-api-${{ env.SHORT_COMMIT_SHA }}-klimadao.vercel.app |