diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index c9ab641..13d98b2 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -2,7 +2,7 @@ name: Deploy to Vercel on: workflow_run: - workflows: ["Lint", "CodeQL"] + workflows: ['Lint', 'CodeQL'] types: - completed @@ -13,52 +13,52 @@ jobs: runs-on: ubuntu-latest steps: - - name: ⬇️ Checkout code - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 + - name: ⬇️ Checkout code + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - - name: ⎔ Setup node - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 - with: - node-version: 20 - - - name: Install pnpm - uses: pnpm/action-setup@a3252b78c470c02df07e9d59298aecedc3ccdd6d - with: - version: 9 - run_install: true + - name: ⎔ Setup node + uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 + with: + node-version: 20 - - name: Install dependencies - run: pnpm install + - name: Install pnpm + uses: pnpm/action-setup@a3252b78c470c02df07e9d59298aecedc3ccdd6d + with: + version: 9 + run_install: true - - name: Install Vercel CLI - run: npm install -g vercel@latest + - name: Install dependencies + run: pnpm install - - name: Deploy to Vercel - run: vercel --token ${{ secrets.VERCEL_TOKEN }} - env: - VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} - VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} + - name: Install Vercel CLI + run: npm install -g vercel@latest - - name: Set CORS origin on Heroku - if: github.event.action == 'opened' || github.event.action == 'reopened' || github.event.action == 'synchronize' - run: | - PR_NUMBER=${{ github.event.number }} - DEPLOYMENT_URL=$(vercel --token ${{ secrets.VERCEL_TOKEN }} --confirm) - CURRENT_ORIGINS=$(heroku config:get ORIGINS --app ${{ secrets.HEROKU_APP_NAME }}) - NEW_ORIGINS="${CURRENT_ORIGINS},${DEPLOYMENT_URL}" - heroku config:set ORIGINS=$NEW_ORIGINS --app ${{ secrets.HEROKU_APP_NAME }} - heroku config:set PR_${PR_NUMBER}_DEPLOYMENT_URL=$DEPLOYMENT_URL --app ${{ secrets.HEROKU_APP_NAME }} - env: - HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }} - - - name: Remove CORS origin from Heroku - if: github.event.action == 'closed' - run: | - PR_NUMBER=${{ github.event.number }} - DEPLOYMENT_URL=$(heroku config:get PR_${PR_NUMBER}_DEPLOYMENT_URL --app ${{ secrets.HEROKU_APP_NAME }}) - CURRENT_ORIGINS=$(heroku config:get ORIGINS --app ${{ secrets.HEROKU_APP_NAME }}) - NEW_ORIGINS=$(echo $CURRENT_ORIGINS | sed "s|,$DEPLOYMENT_URL||g" | sed "s|$DEPLOYMENT_URL,||g" | sed "s|$DEPLOYMENT_URL||g") - heroku config:set ORIGINS=$NEW_ORIGINS --app ${{ secrets.HEROKU_APP_NAME }} - heroku config:unset PR_${PR_NUMBER}_DEPLOYMENT_URL --app ${{ secrets.HEROKU_APP_NAME }} - env: - HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }} + - name: Deploy to Vercel + run: vercel --token ${{ secrets.VERCEL_TOKEN }} + env: + VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} + VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} + + - name: Set CORS origin on Heroku + if: github.event.action == 'opened' || github.event.action == 'reopened' || github.event.action == 'synchronize' + run: | + PR_NUMBER=${{ github.event.number }} + DEPLOYMENT_URL=$(vercel --token ${{ secrets.VERCEL_TOKEN }} --confirm) + CURRENT_ORIGINS=$(heroku config:get ORIGINS --app ${{ secrets.HEROKU_APP_NAME }}) + NEW_ORIGINS="${CURRENT_ORIGINS},${DEPLOYMENT_URL}" + heroku config:set ORIGINS=$NEW_ORIGINS --app ${{ secrets.HEROKU_APP_NAME }} + heroku config:set PR_${PR_NUMBER}_DEPLOYMENT_URL=$DEPLOYMENT_URL --app ${{ secrets.HEROKU_APP_NAME }} + env: + HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }} + + - name: Remove CORS origin from Heroku + if: github.event.action == 'closed' + run: | + PR_NUMBER=${{ github.event.number }} + DEPLOYMENT_URL=$(heroku config:get PR_${PR_NUMBER}_DEPLOYMENT_URL --app ${{ secrets.HEROKU_APP_NAME }}) + CURRENT_ORIGINS=$(heroku config:get ORIGINS --app ${{ secrets.HEROKU_APP_NAME }}) + NEW_ORIGINS=$(echo $CURRENT_ORIGINS | sed "s|,$DEPLOYMENT_URL||g" | sed "s|$DEPLOYMENT_URL,||g" | sed "s|$DEPLOYMENT_URL||g") + heroku config:set ORIGINS=$NEW_ORIGINS --app ${{ secrets.HEROKU_APP_NAME }} + heroku config:unset PR_${PR_NUMBER}_DEPLOYMENT_URL --app ${{ secrets.HEROKU_APP_NAME }} + env: + HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }} diff --git a/vercel.json b/vercel.json index 8de62b3..45c873b 100644 --- a/vercel.json +++ b/vercel.json @@ -2,4 +2,4 @@ "git": { "deploymentEnabled": false } -} \ No newline at end of file +}