From b0a498b9f88def38a858f3e5fc56d65a00af503b Mon Sep 17 00:00:00 2001 From: Ruslan Lukoyanov <105169805+rLukoyanov@users.noreply.github.com> Date: Thu, 8 Aug 2024 00:13:10 +0300 Subject: [PATCH] Update Deploy Preview.yml --- .github/workflows/Deploy Preview.yml | 34 ++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/.github/workflows/Deploy Preview.yml b/.github/workflows/Deploy Preview.yml index fe3cfce..778727a 100644 --- a/.github/workflows/Deploy Preview.yml +++ b/.github/workflows/Deploy Preview.yml @@ -6,7 +6,7 @@ on: - main jobs: - build: + build-and-deploy: runs-on: ubuntu-latest steps: @@ -29,4 +29,34 @@ jobs: VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} - run: npx vercel --prod --token $VERCEL_TOKEN --confirm + run: | + npx vercel --prod --token $VERCEL_TOKEN --org-id $VERCEL_ORG_ID --project-id $VERCEL_PROJECT_ID --confirm + id: vercel-deploy + + - name: Get Vercel Deployment URL + run: echo "Vercel Deployment URL: $(npx vercel --token $VERCEL_TOKEN ls --scope $VERCEL_ORG_ID | grep -o 'https://[^ ]*')" > vercel_url.txt + id: get-url + env: + VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} + + - name: Save Deployment URL as GitHub output + id: save-url + uses: actions/github-script@v6 + with: + script: | + const fs = require('fs'); + const url = fs.readFileSync('vercel_url.txt', 'utf8').trim(); + core.setOutput('vercel-url', url); + + - name: Comment on Pull Request + uses: actions/github-script@v6 + with: + script: | + github.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: `Deployed to Vercel: ${url}` + }) + env: + url: ${{ steps.save-url.outputs.vercel-url }}