From 212a59e76ea437cb3c8dd1a6a845f70373c5e228 Mon Sep 17 00:00:00 2001 From: Shravan Goswami Date: Tue, 28 May 2024 20:41:02 +0530 Subject: [PATCH 01/12] testing preview workflow --- .github/workflows/preview.yml | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index bd027b51e..34c708689 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -12,7 +12,7 @@ jobs: if: github.event.action == 'opened' || github.event.action == 'synchronize' runs-on: ubuntu-latest steps: - - name: Checkout + - name: Checkout the repository uses: actions/checkout@v4 - name: Setup Julia @@ -46,19 +46,26 @@ jobs: _freeze/ key: ${{ runner.os }}-primes-${{ github.run_id }} + - name: Checkout gh-pages branch + uses: actions/checkout@v4 + with: + ref: gh-pages + path: gh-pages + - name: Deploy Preview to GitHub Pages run: | PR_NUMBER=${{ github.event.pull_request.number }} PREVIEW_DIR="pr-previews/${PR_NUMBER}" - git config --global user.name "github-actions[bot]" - git config --global user.email "github-actions[bot]@users.noreply.github.com" - git clone --depth 1 --branch gh-pages https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }} gh-pages mkdir -p gh-pages/${PREVIEW_DIR} cp -r _site/* gh-pages/${PREVIEW_DIR} cd gh-pages + git config --global user.name "github-actions[bot]" + git config --global user.email "github-actions[bot]@users.noreply.github.com" git add . git commit -m "Deploy preview for PR ${PR_NUMBER}" git push + env: + GH_PAT: ${{ secrets.GH_PAT }} delete-preview-directory: if: github.event.action == 'closed' || github.event.pull_request.merged == true @@ -80,7 +87,7 @@ jobs: git commit -m "Remove preview for merged PR #${PR_NUMBER}" git push env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_PAT: ${{ secrets.GH_PAT }} comment-preview-url: needs: build-and-preview @@ -90,7 +97,7 @@ jobs: - name: Comment Preview URL uses: actions/github-script@v7 with: - github-token: ${{ secrets.GITHUB_TOKEN }} + github-token: ${{ secrets.GH_PAT }} script: | const prNumber = context.payload.pull_request.number; const repoName = context.repo.repo; @@ -125,4 +132,4 @@ jobs: repo: context.repo.repo, body: commentBody, }); - } \ No newline at end of file + } From 2e57b9cb256d4e174072063ec1e41129cd5a771d Mon Sep 17 00:00:00 2001 From: Shravan Goswami Date: Tue, 28 May 2024 20:57:39 +0530 Subject: [PATCH 02/12] testing preview workflow 2 --- .github/workflows/preview.yml | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index 34c708689..4b5c6ec63 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -12,7 +12,7 @@ jobs: if: github.event.action == 'opened' || github.event.action == 'synchronize' runs-on: ubuntu-latest steps: - - name: Checkout the repository + - name: Checkout uses: actions/checkout@v4 - name: Setup Julia @@ -46,26 +46,21 @@ jobs: _freeze/ key: ${{ runner.os }}-primes-${{ github.run_id }} - - name: Checkout gh-pages branch - uses: actions/checkout@v4 - with: - ref: gh-pages - path: gh-pages - - name: Deploy Preview to GitHub Pages + env: + GH_PAT: ${{ secrets.GH_PAT }} run: | PR_NUMBER=${{ github.event.pull_request.number }} PREVIEW_DIR="pr-previews/${PR_NUMBER}" + git config --global user.name "github-actions[bot]" + git config --global user.email "github-actions[bot]@users.noreply.github.com" + git clone --depth 1 --branch gh-pages https://x-access-token:${{ secrets.GH_PAT }}@github.com/${{ github.repository }} gh-pages mkdir -p gh-pages/${PREVIEW_DIR} cp -r _site/* gh-pages/${PREVIEW_DIR} cd gh-pages - git config --global user.name "github-actions[bot]" - git config --global user.email "github-actions[bot]@users.noreply.github.com" git add . git commit -m "Deploy preview for PR ${PR_NUMBER}" git push - env: - GH_PAT: ${{ secrets.GH_PAT }} delete-preview-directory: if: github.event.action == 'closed' || github.event.pull_request.merged == true @@ -77,6 +72,8 @@ jobs: ref: gh-pages - name: Remove PR Preview Directory + env: + GH_PAT: ${{ secrets.GH_PAT }} run: | PR_NUMBER=${{ github.event.pull_request.number }} PREVIEW_DIR="pr-previews/${PR_NUMBER}" @@ -86,8 +83,6 @@ jobs: git add . git commit -m "Remove preview for merged PR #${PR_NUMBER}" git push - env: - GH_PAT: ${{ secrets.GH_PAT }} comment-preview-url: needs: build-and-preview From d38ed3a87c141c2b92a96704275e30ecb7e2e7a4 Mon Sep 17 00:00:00 2001 From: Shravan Goswami Date: Tue, 28 May 2024 21:03:22 +0530 Subject: [PATCH 03/12] testing preview workflow 3 --- .github/workflows/preview.yml | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index 4b5c6ec63..703536463 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -6,6 +6,10 @@ on: - opened - synchronize - closed + pull_request_target: + types: + - opened + - synchronize jobs: build-and-preview: @@ -13,7 +17,9 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v3 + with: + fetch-depth: 0 - name: Setup Julia uses: julia-actions/setup-julia@v2 @@ -47,14 +53,12 @@ jobs: key: ${{ runner.os }}-primes-${{ github.run_id }} - name: Deploy Preview to GitHub Pages - env: - GH_PAT: ${{ secrets.GH_PAT }} run: | PR_NUMBER=${{ github.event.pull_request.number }} PREVIEW_DIR="pr-previews/${PR_NUMBER}" git config --global user.name "github-actions[bot]" git config --global user.email "github-actions[bot]@users.noreply.github.com" - git clone --depth 1 --branch gh-pages https://x-access-token:${{ secrets.GH_PAT }}@github.com/${{ github.repository }} gh-pages + git clone --depth 1 --branch gh-pages https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }} gh-pages mkdir -p gh-pages/${PREVIEW_DIR} cp -r _site/* gh-pages/${PREVIEW_DIR} cd gh-pages @@ -67,13 +71,12 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout gh-pages branch - uses: actions/checkout@v4 + uses: actions/checkout@v3 with: ref: gh-pages + fetch-depth: 0 - name: Remove PR Preview Directory - env: - GH_PAT: ${{ secrets.GH_PAT }} run: | PR_NUMBER=${{ github.event.pull_request.number }} PREVIEW_DIR="pr-previews/${PR_NUMBER}" @@ -83,6 +86,8 @@ jobs: git add . git commit -m "Remove preview for merged PR #${PR_NUMBER}" git push + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} comment-preview-url: needs: build-and-preview @@ -92,7 +97,7 @@ jobs: - name: Comment Preview URL uses: actions/github-script@v7 with: - github-token: ${{ secrets.GH_PAT }} + github-token: ${{ secrets.GITHUB_TOKEN }} script: | const prNumber = context.payload.pull_request.number; const repoName = context.repo.repo; @@ -127,4 +132,4 @@ jobs: repo: context.repo.repo, body: commentBody, }); - } + } \ No newline at end of file From f86a54352536030441300cdd77d1cf6f0aa89754 Mon Sep 17 00:00:00 2001 From: Shravan Goswami Date: Tue, 28 May 2024 21:16:51 +0530 Subject: [PATCH 04/12] testing preview workflow 4 --- .github/workflows/preview.yml | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index 703536463..3f1d0166f 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -6,10 +6,9 @@ on: - opened - synchronize - closed - pull_request_target: - types: - - opened - - synchronize + +permissions: + pull-requests: write jobs: build-and-preview: @@ -17,9 +16,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 - with: - fetch-depth: 0 + uses: actions/checkout@v4 - name: Setup Julia uses: julia-actions/setup-julia@v2 @@ -71,10 +68,9 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout gh-pages branch - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: ref: gh-pages - fetch-depth: 0 - name: Remove PR Preview Directory run: | From 20f9db6560bb901cd0583dbc11fe7d15d219a0b2 Mon Sep 17 00:00:00 2001 From: Shravan Goswami Date: Wed, 29 May 2024 08:36:53 +0530 Subject: [PATCH 05/12] testing preview workflow 5 --- .github/workflows/preview.yml | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index 3f1d0166f..f72cd8607 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -7,9 +7,6 @@ on: - synchronize - closed -permissions: - pull-requests: write - jobs: build-and-preview: if: github.event.action == 'opened' || github.event.action == 'synchronize' @@ -50,18 +47,20 @@ jobs: key: ${{ runner.os }}-primes-${{ github.run_id }} - name: Deploy Preview to GitHub Pages + env: + GH_PAT: ${{ secrets.GH_PAT }} run: | PR_NUMBER=${{ github.event.pull_request.number }} PREVIEW_DIR="pr-previews/${PR_NUMBER}" git config --global user.name "github-actions[bot]" git config --global user.email "github-actions[bot]@users.noreply.github.com" - git clone --depth 1 --branch gh-pages https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }} gh-pages + git clone --depth 1 --branch gh-pages https://github.com/${{ github.repository }} gh-pages mkdir -p gh-pages/${PREVIEW_DIR} cp -r _site/* gh-pages/${PREVIEW_DIR} cd gh-pages git add . git commit -m "Deploy preview for PR ${PR_NUMBER}" - git push + git push https://${GH_PAT}@github.com/${{ github.repository }} HEAD:gh-pages delete-preview-directory: if: github.event.action == 'closed' || github.event.pull_request.merged == true @@ -73,6 +72,8 @@ jobs: ref: gh-pages - name: Remove PR Preview Directory + env: + GH_PAT: ${{ secrets.GH_PAT }} run: | PR_NUMBER=${{ github.event.pull_request.number }} PREVIEW_DIR="pr-previews/${PR_NUMBER}" @@ -81,9 +82,7 @@ jobs: rm -rf ${PREVIEW_DIR} git add . git commit -m "Remove preview for merged PR #${PR_NUMBER}" - git push - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + git push https://${GH_PAT}@github.com/${{ github.repository }} HEAD:gh-pages comment-preview-url: needs: build-and-preview @@ -93,7 +92,7 @@ jobs: - name: Comment Preview URL uses: actions/github-script@v7 with: - github-token: ${{ secrets.GITHUB_TOKEN }} + github-token: ${{ secrets.GH_PAT }} script: | const prNumber = context.payload.pull_request.number; const repoName = context.repo.repo; @@ -128,4 +127,4 @@ jobs: repo: context.repo.repo, body: commentBody, }); - } \ No newline at end of file + } From 7d6e820199b1366bcba2d82eb5dc55532baf16d7 Mon Sep 17 00:00:00 2001 From: Shravan Goswami Date: Wed, 29 May 2024 08:41:18 +0530 Subject: [PATCH 06/12] testing preview workflow 6 --- .github/workflows/preview.yml | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index f72cd8607..703536463 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -6,6 +6,10 @@ on: - opened - synchronize - closed + pull_request_target: + types: + - opened + - synchronize jobs: build-and-preview: @@ -13,7 +17,9 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v3 + with: + fetch-depth: 0 - name: Setup Julia uses: julia-actions/setup-julia@v2 @@ -47,33 +53,30 @@ jobs: key: ${{ runner.os }}-primes-${{ github.run_id }} - name: Deploy Preview to GitHub Pages - env: - GH_PAT: ${{ secrets.GH_PAT }} run: | PR_NUMBER=${{ github.event.pull_request.number }} PREVIEW_DIR="pr-previews/${PR_NUMBER}" git config --global user.name "github-actions[bot]" git config --global user.email "github-actions[bot]@users.noreply.github.com" - git clone --depth 1 --branch gh-pages https://github.com/${{ github.repository }} gh-pages + git clone --depth 1 --branch gh-pages https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }} gh-pages mkdir -p gh-pages/${PREVIEW_DIR} cp -r _site/* gh-pages/${PREVIEW_DIR} cd gh-pages git add . git commit -m "Deploy preview for PR ${PR_NUMBER}" - git push https://${GH_PAT}@github.com/${{ github.repository }} HEAD:gh-pages + git push delete-preview-directory: if: github.event.action == 'closed' || github.event.pull_request.merged == true runs-on: ubuntu-latest steps: - name: Checkout gh-pages branch - uses: actions/checkout@v4 + uses: actions/checkout@v3 with: ref: gh-pages + fetch-depth: 0 - name: Remove PR Preview Directory - env: - GH_PAT: ${{ secrets.GH_PAT }} run: | PR_NUMBER=${{ github.event.pull_request.number }} PREVIEW_DIR="pr-previews/${PR_NUMBER}" @@ -82,7 +85,9 @@ jobs: rm -rf ${PREVIEW_DIR} git add . git commit -m "Remove preview for merged PR #${PR_NUMBER}" - git push https://${GH_PAT}@github.com/${{ github.repository }} HEAD:gh-pages + git push + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} comment-preview-url: needs: build-and-preview @@ -92,7 +97,7 @@ jobs: - name: Comment Preview URL uses: actions/github-script@v7 with: - github-token: ${{ secrets.GH_PAT }} + github-token: ${{ secrets.GITHUB_TOKEN }} script: | const prNumber = context.payload.pull_request.number; const repoName = context.repo.repo; @@ -127,4 +132,4 @@ jobs: repo: context.repo.repo, body: commentBody, }); - } + } \ No newline at end of file From e59c43d8f0d154041f410a0aee7db120eca98e16 Mon Sep 17 00:00:00 2001 From: Shravan Goswami Date: Wed, 29 May 2024 08:52:21 +0530 Subject: [PATCH 07/12] testing preview workflow 6 --- .github/workflows/preview.yml | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index 703536463..5200f34b8 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -1,15 +1,11 @@ name: PR Preview Workflow on: - pull_request: - types: - - opened - - synchronize - - closed pull_request_target: types: - opened - synchronize + - closed jobs: build-and-preview: @@ -18,8 +14,6 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 - with: - fetch-depth: 0 - name: Setup Julia uses: julia-actions/setup-julia@v2 @@ -74,7 +68,6 @@ jobs: uses: actions/checkout@v3 with: ref: gh-pages - fetch-depth: 0 - name: Remove PR Preview Directory run: | From f94f37313fa03f324b215c1a27a9c7c6ec7e6cab Mon Sep 17 00:00:00 2001 From: Shravan Goswami Date: Wed, 29 May 2024 09:17:59 +0530 Subject: [PATCH 08/12] testing preview workflow 6 --- .github/workflows/preview.yml | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index 5200f34b8..f1323474d 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -1,7 +1,7 @@ name: PR Preview Workflow on: - pull_request_target: + pull_request: types: - opened - synchronize @@ -14,6 +14,9 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 + with: + fetch-depth: 0 # Fetch all history for all branches and tags + ref: ${{ github.event.pull_request.head.ref }} # Checkout the PR branch - name: Setup Julia uses: julia-actions/setup-julia@v2 @@ -46,19 +49,26 @@ jobs: _freeze/ key: ${{ runner.os }}-primes-${{ github.run_id }} + - name: Checkout gh-pages branch + uses: actions/checkout@v3 + with: + ref: gh-pages + path: gh-pages + - name: Deploy Preview to GitHub Pages run: | PR_NUMBER=${{ github.event.pull_request.number }} PREVIEW_DIR="pr-previews/${PR_NUMBER}" - git config --global user.name "github-actions[bot]" - git config --global user.email "github-actions[bot]@users.noreply.github.com" - git clone --depth 1 --branch gh-pages https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }} gh-pages mkdir -p gh-pages/${PREVIEW_DIR} cp -r _site/* gh-pages/${PREVIEW_DIR} cd gh-pages + git config --global user.name "github-actions[bot]" + git config --global user.email "github-actions[bot]@users.noreply.github.com" git add . git commit -m "Deploy preview for PR ${PR_NUMBER}" git push + env: + GH_PAT: ${{ secrets.GH_PAT }} delete-preview-directory: if: github.event.action == 'closed' || github.event.pull_request.merged == true @@ -125,4 +135,4 @@ jobs: repo: context.repo.repo, body: commentBody, }); - } \ No newline at end of file + } From 9176cd6e5b0b1781060e24d7442fb075e11d27b3 Mon Sep 17 00:00:00 2001 From: Shravan Goswami Date: Wed, 29 May 2024 09:36:59 +0530 Subject: [PATCH 09/12] new preview test --- .github/workflows/preview.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index f1323474d..1ae3ef641 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -1,7 +1,7 @@ name: PR Preview Workflow on: - pull_request: + pull_request_target: types: - opened - synchronize @@ -15,7 +15,6 @@ jobs: - name: Checkout uses: actions/checkout@v3 with: - fetch-depth: 0 # Fetch all history for all branches and tags ref: ${{ github.event.pull_request.head.ref }} # Checkout the PR branch - name: Setup Julia @@ -135,4 +134,3 @@ jobs: repo: context.repo.repo, body: commentBody, }); - } From 27f5c0d7bd0d3b85c6368a9dd2dd5cb7c9ff4ec3 Mon Sep 17 00:00:00 2001 From: Shravan Goswami Date: Wed, 29 May 2024 09:50:18 +0530 Subject: [PATCH 10/12] new preview test 1 --- .github/workflows/preview.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index 1ae3ef641..77f8a5c8e 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -15,7 +15,8 @@ jobs: - name: Checkout uses: actions/checkout@v3 with: - ref: ${{ github.event.pull_request.head.ref }} # Checkout the PR branch + fetch-depth: 0 # Fetch all history for all branches and tags + ref: ${{ github.event.pull_request.head.sha }} # Ensure correct commit - name: Setup Julia uses: julia-actions/setup-julia@v2 From 56f397ba1b9a3f066ec43340ee9e828dffc5ee0d Mon Sep 17 00:00:00 2001 From: Shravan Goswami Date: Wed, 29 May 2024 10:17:28 +0530 Subject: [PATCH 11/12] final workflow --- .github/workflows/preview.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index 77f8a5c8e..3a103eee8 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -15,8 +15,7 @@ jobs: - name: Checkout uses: actions/checkout@v3 with: - fetch-depth: 0 # Fetch all history for all branches and tags - ref: ${{ github.event.pull_request.head.sha }} # Ensure correct commit + ref: ${{ github.event.pull_request.head.sha }} - name: Setup Julia uses: julia-actions/setup-julia@v2 @@ -135,3 +134,4 @@ jobs: repo: context.repo.repo, body: commentBody, }); + \ No newline at end of file From 973e6d07530f8718a1372152223a86efad24c2a9 Mon Sep 17 00:00:00 2001 From: Shravan Goswami Date: Wed, 29 May 2024 10:39:33 +0530 Subject: [PATCH 12/12] final workflow --- .github/workflows/preview.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index 3a103eee8..067f5b701 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -134,4 +134,5 @@ jobs: repo: context.repo.repo, body: commentBody, }); + } \ No newline at end of file