Various API Fixes #596
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: | |
branches: | |
- staging | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Pull Vercel Environment Information | |
run: vercel env pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }} .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@v3 | |
- 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 |