From 3f65497b67e7ff6ed4d2409a2090fca706074f32 Mon Sep 17 00:00:00 2001 From: Marc Garcia Date: Fri, 20 Jan 2023 23:37:11 +0700 Subject: [PATCH 1/8] WIP: Trigger preview of the web/docs --- .github/workflows/docbuild-and-upload.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/docbuild-and-upload.yml b/.github/workflows/docbuild-and-upload.yml index 908259597cafb..062274de54dc9 100644 --- a/.github/workflows/docbuild-and-upload.yml +++ b/.github/workflows/docbuild-and-upload.yml @@ -87,3 +87,12 @@ jobs: name: website path: web/build retention-days: 14 + + - name: Trigger web/doc preview + run: | + curl -X POST https://pandas.pydata.org/preview/submit/$RUN_ID/$PR_ID/ + echo "Preview docs for this PR at: https://pandas.pydata.org/preview/$PR_ID/" + env: + RUN_ID: ${{ github.run_id }} + PR_ID: ${{ github.event.pull_request.number }} + if: github.event_name == 'pull_request' From 5f8d199c8f2e846cfb8f02c558c388f481c7c140 Mon Sep 17 00:00:00 2001 From: Marc Garcia Date: Thu, 26 Jan 2023 16:43:46 +0700 Subject: [PATCH 2/8] Moving trigger to separate job --- .github/workflows/docbuild-and-upload.yml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/workflows/docbuild-and-upload.yml b/.github/workflows/docbuild-and-upload.yml index 062274de54dc9..d5441e8f3c869 100644 --- a/.github/workflows/docbuild-and-upload.yml +++ b/.github/workflows/docbuild-and-upload.yml @@ -88,11 +88,23 @@ jobs: path: web/build retention-days: 14 + outputs: + run_id: ${{ github.run_id }} # I assume run_id is different in different jobs, need to check + + + preview_website: + name: Preview website and docs + runs-on: ubuntu-22.04 + needs: web_and_docs + steps: + - name: Trigger web/doc preview run: | curl -X POST https://pandas.pydata.org/preview/submit/$RUN_ID/$PR_ID/ echo "Preview docs for this PR at: https://pandas.pydata.org/preview/$PR_ID/" + echo "This run id: $THIS_RUN_ID, other job run id: $RUN_ID" env: - RUN_ID: ${{ github.run_id }} + THIS_RUN_ID: ${{ github.run_id }} + RUN_ID: ${{ needs.web_and_docs.outputs.run_id }} PR_ID: ${{ github.event.pull_request.number }} if: github.event_name == 'pull_request' From 56a2fe5aa1596f7169b679c6137a5d53b99f5dbb Mon Sep 17 00:00:00 2001 From: Marc Garcia Date: Thu, 26 Jan 2023 18:32:46 +0700 Subject: [PATCH 3/8] Triggering preview from a different job didn't work, reverting --- .github/workflows/docbuild-and-upload.yml | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/.github/workflows/docbuild-and-upload.yml b/.github/workflows/docbuild-and-upload.yml index d5441e8f3c869..062274de54dc9 100644 --- a/.github/workflows/docbuild-and-upload.yml +++ b/.github/workflows/docbuild-and-upload.yml @@ -88,23 +88,11 @@ jobs: path: web/build retention-days: 14 - outputs: - run_id: ${{ github.run_id }} # I assume run_id is different in different jobs, need to check - - - preview_website: - name: Preview website and docs - runs-on: ubuntu-22.04 - needs: web_and_docs - steps: - - name: Trigger web/doc preview run: | curl -X POST https://pandas.pydata.org/preview/submit/$RUN_ID/$PR_ID/ echo "Preview docs for this PR at: https://pandas.pydata.org/preview/$PR_ID/" - echo "This run id: $THIS_RUN_ID, other job run id: $RUN_ID" env: - THIS_RUN_ID: ${{ github.run_id }} - RUN_ID: ${{ needs.web_and_docs.outputs.run_id }} + RUN_ID: ${{ github.run_id }} PR_ID: ${{ github.event.pull_request.number }} if: github.event_name == 'pull_request' From 9de033b99d01c564f2143daadf9b5a7470c7fede Mon Sep 17 00:00:00 2001 From: Marc Garcia Date: Fri, 27 Jan 2023 01:45:44 +0700 Subject: [PATCH 4/8] Removing url in logs, it will be posted as a comment --- .github/workflows/docbuild-and-upload.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/docbuild-and-upload.yml b/.github/workflows/docbuild-and-upload.yml index 062274de54dc9..c5bf3abf592e6 100644 --- a/.github/workflows/docbuild-and-upload.yml +++ b/.github/workflows/docbuild-and-upload.yml @@ -89,9 +89,7 @@ jobs: retention-days: 14 - name: Trigger web/doc preview - run: | - curl -X POST https://pandas.pydata.org/preview/submit/$RUN_ID/$PR_ID/ - echo "Preview docs for this PR at: https://pandas.pydata.org/preview/$PR_ID/" + run: curl -X POST https://pandas.pydata.org/preview/submit/$RUN_ID/$PR_ID/ env: RUN_ID: ${{ github.run_id }} PR_ID: ${{ github.event.pull_request.number }} From 335e2027d519b05724660d9ad6b70b3255a4805e Mon Sep 17 00:00:00 2001 From: Marc Garcia Date: Sun, 26 Feb 2023 19:51:30 +0100 Subject: [PATCH 5/8] Add action to show preview url --- .github/workflows/preview-docs.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/workflows/preview-docs.yml diff --git a/.github/workflows/preview-docs.yml b/.github/workflows/preview-docs.yml new file mode 100644 index 0000000000000..7d7ca9840eb89 --- /dev/null +++ b/.github/workflows/preview-docs.yml @@ -0,0 +1,22 @@ +name: Assign +on: + issue_comment: + types: created + +permissions: + contents: read + +jobs: + issue_assign: + permissions: + issues: write + pull-requests: write + runs-on: ubuntu-22.04 + steps: + - if: github.event.comment.body == '/preview' + run: | + if curl --output /dev/null --silent --head --fail "https://pandas.pydata.org/preview/${{ github.event.issue.number }}"; then + curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -d '{"body": "Website preview of this PR available at: https://pandas.pydata.org/preview/${{ github.event.issue.number }}"}' https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/comments + else + curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -d '{"body": "No preview found for PR ${{ github.event.issue.number }}"}' https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/comments + fi From 7149ac5b2238f305a7944e198e43391555b78420 Mon Sep 17 00:00:00 2001 From: Marc Garcia Date: Sun, 26 Feb 2023 19:53:23 +0100 Subject: [PATCH 6/8] Fix indentation --- .github/workflows/preview-docs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/preview-docs.yml b/.github/workflows/preview-docs.yml index 7d7ca9840eb89..4e5e4a4770e41 100644 --- a/.github/workflows/preview-docs.yml +++ b/.github/workflows/preview-docs.yml @@ -16,7 +16,7 @@ jobs: - if: github.event.comment.body == '/preview' run: | if curl --output /dev/null --silent --head --fail "https://pandas.pydata.org/preview/${{ github.event.issue.number }}"; then - curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -d '{"body": "Website preview of this PR available at: https://pandas.pydata.org/preview/${{ github.event.issue.number }}"}' https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/comments + curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -d '{"body": "Website preview of this PR available at: https://pandas.pydata.org/preview/${{ github.event.issue.number }}"}' https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/comments else curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -d '{"body": "No preview found for PR ${{ github.event.issue.number }}"}' https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/comments fi From 5e3418bf7518f78bc9972ae1b313c2952e00d3a0 Mon Sep 17 00:00:00 2001 From: Marc Garcia Date: Sun, 26 Feb 2023 22:16:01 +0100 Subject: [PATCH 7/8] Fixing url (tailing slash needed) and making PR number clickable --- .github/workflows/preview-docs.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/preview-docs.yml b/.github/workflows/preview-docs.yml index 4e5e4a4770e41..5a766f5073178 100644 --- a/.github/workflows/preview-docs.yml +++ b/.github/workflows/preview-docs.yml @@ -15,8 +15,8 @@ jobs: steps: - if: github.event.comment.body == '/preview' run: | - if curl --output /dev/null --silent --head --fail "https://pandas.pydata.org/preview/${{ github.event.issue.number }}"; then - curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -d '{"body": "Website preview of this PR available at: https://pandas.pydata.org/preview/${{ github.event.issue.number }}"}' https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/comments + if curl --output /dev/null --silent --head --fail "https://pandas.pydata.org/preview/${{ github.event.issue.number }}/"; then + curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -d '{"body": "Website preview of this PR available at: https://pandas.pydata.org/preview/${{ github.event.issue.number }}/"}' https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/comments else - curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -d '{"body": "No preview found for PR ${{ github.event.issue.number }}"}' https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/comments + curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -d '{"body": "No preview found for PR #${{ github.event.issue.number }}"}' https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/comments fi From acbd02916aef6d289768b6c8e9ce22c28db74aa0 Mon Sep 17 00:00:00 2001 From: Marc Garcia Date: Mon, 27 Feb 2023 18:25:39 +0100 Subject: [PATCH 8/8] Fix name of build and job, improved message when no preview is found --- .github/workflows/preview-docs.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/preview-docs.yml b/.github/workflows/preview-docs.yml index 5a766f5073178..8f73db283289c 100644 --- a/.github/workflows/preview-docs.yml +++ b/.github/workflows/preview-docs.yml @@ -1,4 +1,4 @@ -name: Assign +name: Preview docs on: issue_comment: types: created @@ -7,7 +7,7 @@ permissions: contents: read jobs: - issue_assign: + preview_docs: permissions: issues: write pull-requests: write @@ -18,5 +18,5 @@ jobs: if curl --output /dev/null --silent --head --fail "https://pandas.pydata.org/preview/${{ github.event.issue.number }}/"; then curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -d '{"body": "Website preview of this PR available at: https://pandas.pydata.org/preview/${{ github.event.issue.number }}/"}' https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/comments else - curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -d '{"body": "No preview found for PR #${{ github.event.issue.number }}"}' https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/comments + curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -d '{"body": "No preview found for PR #${{ github.event.issue.number }}. Did the docs build complete?"}' https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/comments fi