From 1e55377208f74b638e93df88d199333698ed9236 Mon Sep 17 00:00:00 2001 From: Mel Massadian Date: Wed, 9 Aug 2023 23:08:10 +0200 Subject: [PATCH] =?UTF-8?q?ci:=20=E2=9C=A8=20check=20for=20forks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Explained here: https://github.com/rossjrw/pr-preview-action/issues/54 --- .github/workflows/pr-preview.yml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/pr-preview.yml b/.github/workflows/pr-preview.yml index fcc4d4143..9b2defdc5 100644 --- a/.github/workflows/pr-preview.yml +++ b/.github/workflows/pr-preview.yml @@ -23,13 +23,18 @@ jobs: outputs: level: ${{ steps.access_check.outputs.has-write }} steps: - - name: 🗝️ Check if author has write access + - name: 🗝️ Check PR origin & author write access id: access_check run: | - PERMISSION=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/${{ github.repository }}/collaborators/${{ github.event.pull_request.user.login }}/permission" | jq -r .permission) - echo "Workflow ran by ${{ github.actor }}" - echo "Permissions of ${{ github.event.pull_request.user.login }}: ${PERMISSION}" - echo "has-write=${PERMISSION}" >> $GITHUB_OUTPUT + if [ "${{ github.event.pull_request.head.repo.full_name }}" != "teia-community/teia-ui" ]; then + echo "has-write=none" >> $GITHUB_OUTPUT + exit 0 + else + PERMISSION=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/${{ github.repository }}/collaborators/${{ github.event.pull_request.user.login }}/permission" | jq -r .permission) + echo "Workflow ran by ${{ github.actor }}" + echo "Permissions of ${{ github.event.pull_request.user.login }} (PR author): ${PERMISSION}" + echo "has-write=${PERMISSION}" >> $GITHUB_OUTPUT + fi env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}