From b71f5d10dbde16d9797c151c8fb02aaa1337e6ac Mon Sep 17 00:00:00 2001 From: Saransh Chopra Date: Wed, 14 Aug 2024 15:49:40 +0100 Subject: [PATCH 1/2] fix: split deployment job and give it write permission --- .github/workflows/build_site.yml | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build_site.yml b/.github/workflows/build_site.yml index 0dc5c60d..78b08046 100644 --- a/.github/workflows/build_site.yml +++ b/.github/workflows/build_site.yml @@ -1,4 +1,4 @@ -name: Build website +name: Build and deploy website on: push: branches: @@ -6,8 +6,10 @@ on: pull_request: branches: - main + workflow_dispatch: + jobs: - Build-website: + build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -51,10 +53,20 @@ jobs: uses: actions/upload-pages-artifact@v3 with: path: _site + + deploy: + needs: build + permissions: + pages: write + id-token: write + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + steps: - name: Deploy to GitHub Pages if: > - success() - && github.ref == 'refs/heads/main' + github.ref == 'refs/heads/main' && github.repository == 'UCL/rsd-engineeringcourse' id: deployment uses: actions/deploy-pages@v4 From a2282ecfbc525310fc912dc664c687238ff6d025 Mon Sep 17 00:00:00 2001 From: Saransh Chopra Date: Wed, 14 Aug 2024 16:11:23 +0100 Subject: [PATCH 2/2] move the if condition at top --- .github/workflows/build_site.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build_site.yml b/.github/workflows/build_site.yml index 78b08046..e04b183e 100644 --- a/.github/workflows/build_site.yml +++ b/.github/workflows/build_site.yml @@ -55,6 +55,9 @@ jobs: path: _site deploy: + if: > + github.ref == 'refs/heads/main' + && github.repository == 'UCL/rsd-engineeringcourse' needs: build permissions: pages: write @@ -65,8 +68,5 @@ jobs: runs-on: ubuntu-latest steps: - name: Deploy to GitHub Pages - if: > - github.ref == 'refs/heads/main' - && github.repository == 'UCL/rsd-engineeringcourse' id: deployment uses: actions/deploy-pages@v4