From a92e4c2bc51f99be2bde49a9522f002dd299f36b Mon Sep 17 00:00:00 2001 From: Ricardo Zanini Date: Thu, 7 Mar 2024 16:27:35 -0300 Subject: [PATCH] NO-ISSUE - Try to fix PR id not found in github event Signed-off-by: Ricardo Zanini --- .github/workflows/pr-preview-publish.yml | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pr-preview-publish.yml b/.github/workflows/pr-preview-publish.yml index 45dc4b168..d6d7127c2 100644 --- a/.github/workflows/pr-preview-publish.yml +++ b/.github/workflows/pr-preview-publish.yml @@ -31,6 +31,14 @@ jobs: if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' runs-on: ubuntu-latest steps: + - name: Get PR number + id: get_pr_number + run: | + PR_URL=$(curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" ${{ github.event.workflow_run.url }}/pull_requests | jq -r '.pull_requests[0].url') + PR_NUMBER=$(basename $PR_URL) + echo "PR number: $PR_NUMBER" + shell: bash + - name: Download PR Artifact uses: actions/download-artifact@v4 with: @@ -41,7 +49,7 @@ jobs: - name: Publish to Surge for preview id: deploy - run: npx surge ./build/site --domain https://sonataflow-docs-preview-pr-${{ github.event.workflow_run.pull_requests[0].number }}.surge.sh --token ${{ secrets.SURGE_LOCAL_TOKEN }} + run: npx surge ./build/site --domain https://sonataflow-docs-preview-pr-${{ env.PR_NUMBER }}.surge.sh --token ${{ secrets.SURGE_LOCAL_TOKEN }} - name: Update PR status comment on success if: success() @@ -49,10 +57,10 @@ jobs: with: token: ${{ secrets.GITHUB_TOKEN }} body: | - 🎊 PR Preview ${{ github.sha }} has been successfully built and deployed. See the documentation preview: https://sonataflow-docs-preview-pr-${{ github.event.workflow_run.pull_requests[0].number }}.surge.sh + 🎊 PR Preview ${{ github.sha }} has been successfully built and deployed. See the documentation preview: https://sonataflow-docs-preview-pr-${{ env.PR_NUMBER }}.surge.sh body-include: "" - number: ${{ github.event.workflow_run.pull_requests[0].number }} + number: ${{ env.PR_NUMBER }} emojis: "heart" - name: Update PR status comment on failure @@ -65,5 +73,5 @@ jobs: body-include: "" - number: ${{ github.event.workflow_run.pull_requests[0].number }} + number: ${{ env.PR_NUMBER }} emojis: "confused"