From 06c73aa12015235faaa6250c7df7f018435a0e92 Mon Sep 17 00:00:00 2001 From: Pietro Monticone <38562595+pitmonticone@users.noreply.github.com> Date: Thu, 26 Sep 2024 23:21:32 +0200 Subject: [PATCH 1/9] Update blueprint.yml --- .github/workflows/blueprint.yml | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/.github/workflows/blueprint.yml b/.github/workflows/blueprint.yml index 8ce46079..f49953da 100644 --- a/.github/workflows/blueprint.yml +++ b/.github/workflows/blueprint.yml @@ -14,17 +14,29 @@ concurrency: group: ${{ github.ref }} # Group runs by the ref (branch or PR) cancel-in-progress: true # Cancel any ongoing runs in the same group -# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages and modify PR labels permissions: - contents: read # Read access to repository contents - pages: write # Write access to GitHub Pages - id-token: write # Write access to ID tokens + contents: read # Read access to repository contents + pages: write # Write access to GitHub Pages + id-token: write # Write access to ID tokens + issues: write # Write access to issues and pull requests (needed for labeling) jobs: build_project: runs-on: ubuntu-latest name: Build project steps: + - name: Add 'awaiting-CI' label + if: github.event_name == 'pull_request' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + curl -s -X POST \ + -H "Authorization: token $GITHUB_TOKEN" \ + -H "Accept: application/vnd.github.v3+json" \ + https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/labels \ + -d '{"labels":["awaiting-CI"]}' + - name: Checkout project uses: actions/checkout@v4 with: @@ -125,3 +137,13 @@ jobs: - name: Make sure the API documentation cache works run: mv home_page/docs .lake/build/doc + + - name: Remove 'awaiting-CI' label + if: always() && github.event_name == 'pull_request' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + curl -s -X DELETE \ + -H "Authorization: token $GITHUB_TOKEN" \ + -H "Accept: application/vnd.github.v3+json" \ + https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/labels/awaiting-CI From b3d16c470577ba07208cb0c30c56743203d076d4 Mon Sep 17 00:00:00 2001 From: Pietro Monticone <38562595+pitmonticone@users.noreply.github.com> Date: Thu, 26 Sep 2024 23:42:53 +0200 Subject: [PATCH 2/9] Update blueprint.yml --- .github/workflows/blueprint.yml | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/.github/workflows/blueprint.yml b/.github/workflows/blueprint.yml index f49953da..3cac89c6 100644 --- a/.github/workflows/blueprint.yml +++ b/.github/workflows/blueprint.yml @@ -28,14 +28,10 @@ jobs: steps: - name: Add 'awaiting-CI' label if: github.event_name == 'pull_request' - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - curl -s -X POST \ - -H "Authorization: token $GITHUB_TOKEN" \ - -H "Accept: application/vnd.github.v3+json" \ - https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/labels \ - -d '{"labels":["awaiting-CI"]}' + uses: actions-ecosystem/action-add-labels@v1 + with: + labels: awaiting-CI + number: ${{ github.event.pull_request.number }} - name: Checkout project uses: actions/checkout@v4 @@ -140,10 +136,7 @@ jobs: - name: Remove 'awaiting-CI' label if: always() && github.event_name == 'pull_request' - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - curl -s -X DELETE \ - -H "Authorization: token $GITHUB_TOKEN" \ - -H "Accept: application/vnd.github.v3+json" \ - https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/labels/awaiting-CI + uses: actions-ecosystem/action-remove-labels@v1 + with: + labels: awaiting-CI + number: ${{ github.event.pull_request.number }} From c24ef33b74b3c3079cdbec0419fb87545595b164 Mon Sep 17 00:00:00 2001 From: Pietro Monticone <38562595+pitmonticone@users.noreply.github.com> Date: Thu, 26 Sep 2024 23:45:17 +0200 Subject: [PATCH 3/9] Update blueprint.yml --- .github/workflows/blueprint.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/blueprint.yml b/.github/workflows/blueprint.yml index 3cac89c6..12f34e10 100644 --- a/.github/workflows/blueprint.yml +++ b/.github/workflows/blueprint.yml @@ -30,6 +30,7 @@ jobs: if: github.event_name == 'pull_request' uses: actions-ecosystem/action-add-labels@v1 with: + github_token: ${{ secrets.GITHUB_TOKEN }} labels: awaiting-CI number: ${{ github.event.pull_request.number }} @@ -138,5 +139,6 @@ jobs: if: always() && github.event_name == 'pull_request' uses: actions-ecosystem/action-remove-labels@v1 with: + github_token: ${{ secrets.GITHUB_TOKEN }} labels: awaiting-CI number: ${{ github.event.pull_request.number }} From 8510b28651508516f6299ca5be174c2a4e82ca4c Mon Sep 17 00:00:00 2001 From: Pietro Monticone <38562595+pitmonticone@users.noreply.github.com> Date: Thu, 26 Sep 2024 23:52:30 +0200 Subject: [PATCH 4/9] Update blueprint.yml --- .github/workflows/blueprint.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/blueprint.yml b/.github/workflows/blueprint.yml index 12f34e10..46145142 100644 --- a/.github/workflows/blueprint.yml +++ b/.github/workflows/blueprint.yml @@ -27,10 +27,9 @@ jobs: name: Build project steps: - name: Add 'awaiting-CI' label - if: github.event_name == 'pull_request' + if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository uses: actions-ecosystem/action-add-labels@v1 with: - github_token: ${{ secrets.GITHUB_TOKEN }} labels: awaiting-CI number: ${{ github.event.pull_request.number }} @@ -139,6 +138,5 @@ jobs: if: always() && github.event_name == 'pull_request' uses: actions-ecosystem/action-remove-labels@v1 with: - github_token: ${{ secrets.GITHUB_TOKEN }} labels: awaiting-CI number: ${{ github.event.pull_request.number }} From 0be041850fe6a55e7a6286bd85e800fa66b4b404 Mon Sep 17 00:00:00 2001 From: Pietro Monticone <38562595+pitmonticone@users.noreply.github.com> Date: Fri, 27 Sep 2024 00:01:45 +0200 Subject: [PATCH 5/9] Update blueprint.yml --- .github/workflows/blueprint.yml | 39 ++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/.github/workflows/blueprint.yml b/.github/workflows/blueprint.yml index 46145142..f1357610 100644 --- a/.github/workflows/blueprint.yml +++ b/.github/workflows/blueprint.yml @@ -27,11 +27,18 @@ jobs: name: Build project steps: - name: Add 'awaiting-CI' label - if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository - uses: actions-ecosystem/action-add-labels@v1 + if: > + github.event_name == 'pull_request' && + github.event.pull_request.head.repo.full_name == github.repository + uses: actions/github-script@v6 with: - labels: awaiting-CI - number: ${{ github.event.pull_request.number }} + script: | + await github.issues.addLabels({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + labels: ['awaiting-CI'], + }); - name: Checkout project uses: actions/checkout@v4 @@ -135,8 +142,24 @@ jobs: run: mv home_page/docs .lake/build/doc - name: Remove 'awaiting-CI' label - if: always() && github.event_name == 'pull_request' - uses: actions-ecosystem/action-remove-labels@v1 + if: > + always() && + github.event_name == 'pull_request' && + github.event.pull_request.head.repo.full_name == github.repository + uses: actions/github-script@v6 with: - labels: awaiting-CI - number: ${{ github.event.pull_request.number }} + script: | + try { + await github.issues.removeLabel({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + name: 'awaiting-CI', + }); + } catch (error) { + if (error.status === 404) { + console.log('Label "awaiting-CI" does not exist on this issue.'); + } else { + throw error; + } + } From 8f14e339878040548df01e21fb142a1620ee4f25 Mon Sep 17 00:00:00 2001 From: Pietro Monticone <38562595+pitmonticone@users.noreply.github.com> Date: Fri, 27 Sep 2024 00:04:39 +0200 Subject: [PATCH 6/9] add `rest` namespace --- .github/workflows/blueprint.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/blueprint.yml b/.github/workflows/blueprint.yml index f1357610..d280ed4f 100644 --- a/.github/workflows/blueprint.yml +++ b/.github/workflows/blueprint.yml @@ -33,7 +33,7 @@ jobs: uses: actions/github-script@v6 with: script: | - await github.issues.addLabels({ + github.rest.issues.addLabels({ owner: context.repo.owner, repo: context.repo.repo, issue_number: context.issue.number, @@ -150,7 +150,7 @@ jobs: with: script: | try { - await github.issues.removeLabel({ + await github.rest.issues.removeLabel({ owner: context.repo.owner, repo: context.repo.repo, issue_number: context.issue.number, From 5015bf25c065543407125baa2e30c6f3c61f69eb Mon Sep 17 00:00:00 2001 From: Pietro Monticone <38562595+pitmonticone@users.noreply.github.com> Date: Fri, 27 Sep 2024 00:12:47 +0200 Subject: [PATCH 7/9] Use `curl` --- .github/workflows/blueprint.yml | 37 ++++++++++----------------------- 1 file changed, 11 insertions(+), 26 deletions(-) diff --git a/.github/workflows/blueprint.yml b/.github/workflows/blueprint.yml index d280ed4f..c31388f3 100644 --- a/.github/workflows/blueprint.yml +++ b/.github/workflows/blueprint.yml @@ -30,15 +30,12 @@ jobs: if: > github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository - uses: actions/github-script@v6 - with: - script: | - github.rest.issues.addLabels({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: context.issue.number, - labels: ['awaiting-CI'], - }); + run: | + curl --request POST \ + --url https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/labels \ + --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \ + --header 'Content-Type: application/json' \ + --data '["awaiting-CI"]' - name: Checkout project uses: actions/checkout@v4 @@ -146,20 +143,8 @@ jobs: always() && github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository - uses: actions/github-script@v6 - with: - script: | - try { - await github.rest.issues.removeLabel({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: context.issue.number, - name: 'awaiting-CI', - }); - } catch (error) { - if (error.status === 404) { - console.log('Label "awaiting-CI" does not exist on this issue.'); - } else { - throw error; - } - } + run: | + curl --request DELETE \ + --url https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/labels/awaiting-CI \ + --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \ + --header 'Content-Type: application/json' From c6ef94795563f9b2469295be7a542c83c7bfe9e6 Mon Sep 17 00:00:00 2001 From: Pietro Monticone <38562595+pitmonticone@users.noreply.github.com> Date: Fri, 27 Sep 2024 00:18:53 +0200 Subject: [PATCH 8/9] Update blueprint.yml --- .github/workflows/blueprint.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/blueprint.yml b/.github/workflows/blueprint.yml index c31388f3..9d8aa3de 100644 --- a/.github/workflows/blueprint.yml +++ b/.github/workflows/blueprint.yml @@ -19,7 +19,8 @@ permissions: contents: read # Read access to repository contents pages: write # Write access to GitHub Pages id-token: write # Write access to ID tokens - issues: write # Write access to issues and pull requests (needed for labeling) + issues: write # Write access to issues + pull-requests: write # Write access to pull requests jobs: build_project: @@ -28,8 +29,7 @@ jobs: steps: - name: Add 'awaiting-CI' label if: > - github.event_name == 'pull_request' && - github.event.pull_request.head.repo.full_name == github.repository + github.event_name == 'pull_request' run: | curl --request POST \ --url https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/labels \ @@ -141,8 +141,7 @@ jobs: - name: Remove 'awaiting-CI' label if: > always() && - github.event_name == 'pull_request' && - github.event.pull_request.head.repo.full_name == github.repository + github.event_name == 'pull_request' run: | curl --request DELETE \ --url https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/labels/awaiting-CI \ From 563c8bdfee184c7b8d02a55cf74a0ea3a7840601 Mon Sep 17 00:00:00 2001 From: Pietro Monticone <38562595+pitmonticone@users.noreply.github.com> Date: Fri, 27 Sep 2024 01:12:23 +0200 Subject: [PATCH 9/9] Build and deploy website on push only --- .github/workflows/blueprint.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/blueprint.yml b/.github/workflows/blueprint.yml index 9d8aa3de..4f318260 100644 --- a/.github/workflows/blueprint.yml +++ b/.github/workflows/blueprint.yml @@ -115,6 +115,7 @@ jobs: find home_page/docs -name "*.hash" -delete - name: Bundle dependencies + if: github.event_name == 'push' uses: ruby/setup-ruby@v1 with: working-directory: home_page @@ -122,16 +123,18 @@ jobs: bundler-cache: true # Enable caching for bundler - name: Build website using Jekyll - if: env.HOME_PAGE_EXISTS == 'true' + if: github.event_name == 'push' && env.HOME_PAGE_EXISTS == 'true' working-directory: home_page run: JEKYLL_ENV=production bundle exec jekyll build # Note this will also copy the blueprint and API doc into home_page/_site - name: "Upload website (API documentation, blueprint and any home page)" + if: github.event_name == 'push' uses: actions/upload-pages-artifact@v3 with: path: ${{ env.HOME_PAGE_EXISTS == 'true' && 'home_page/_site' || 'home_page/' }} - name: Deploy to GitHub Pages + if: github.event_name == 'push' id: deployment uses: actions/deploy-pages@v4