This is an automated email from the ASF dual-hosted git repository. zregvart pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel-website.git
The following commit(s) were added to refs/heads/main by this push: new ebfd276 fix: pass only the PR number and validate it ebfd276 is described below commit ebfd276dac4e77b5779a002bccb1a763a63bc049 Author: Zoran Regvart <zo...@regvart.com> AuthorDate: Fri Dec 10 21:24:41 2021 +0100 fix: pass only the PR number and validate it We don't need to pass `github.event.pull_request.html_url` in `./pull_request/html_url` in the archive, and we should validate that `./pull_request/number` is a number and we should read only the first line from that file. --- .github/workflows/pr.yaml | 1 - .github/workflows/preview.yaml | 9 +++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index e45575f..d432c83 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -39,7 +39,6 @@ jobs: run: | mkdir pull_request echo ${{ github.event.pull_request.number }} > ./pull_request/number - echo ${{ github.event.pull_request.html_url }} > ./pull_request/html_url - name: Upload artifacts uses: actions/upload-artifact@v2 with: diff --git a/.github/workflows/preview.yaml b/.github/workflows/preview.yaml index 4e62340..784aa06 100644 --- a/.github/workflows/preview.yaml +++ b/.github/workflows/preview.yaml @@ -26,6 +26,8 @@ on: jobs: preview: runs-on: ubuntu-latest + permissions: + issues: write if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' steps: - name: Checkout @@ -57,9 +59,12 @@ jobs: NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} run: | - DEPLOY_URL=$(yarn preview:netlify --alias="pr-$(cat pull_request/number)" --message="Preview for $(cat pull_request/html_url)" --json 2> /dev/null |jq -r .deploy_url) + PR_NUMBER=$(head -1 pull_request/number) + PR_NUMBER=${PR_NUMBER//[^0-9]/} + PR_URL="https://github.com/apache/camel-website/pull/${PR_NUMBER}" + DEPLOY_URL=$(yarn preview:netlify --alias="pr-${PR_NUMBER}" --message="Preview for ${PR_URL}" --json 2> /dev/null |jq -r .deploy_url) echo "DEPLOY_URL=${DEPLOY_URL}" >> $GITHUB_ENV - echo "ISSUE_NUMBER=$(cat pull_request/number)" >> $GITHUB_ENV + echo "ISSUE_NUMBER=${PR_NUMBER}" >> $GITHUB_ENV - uses: actions/github-script@v3 with: github-token: ${{ secrets.GITHUB_TOKEN }}