From 331217767ebcbf802cc77b797b161a0643b49b78 Mon Sep 17 00:00:00 2001 From: Mrugesh Mohapatra <1884376+raisedadead@users.noreply.github.com> Date: Tue, 30 May 2023 15:21:37 +0530 Subject: [PATCH] fix: add action to block change made on GitHub (#208) --- .github/workflows/dont-use-github.yml | 28 +++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .github/workflows/dont-use-github.yml diff --git a/.github/workflows/dont-use-github.yml b/.github/workflows/dont-use-github.yml new file mode 100644 index 0000000..84a1eb8 --- /dev/null +++ b/.github/workflows/dont-use-github.yml @@ -0,0 +1,28 @@ +name: Do not use GitHub Web + +on: + pull_request: + types: [synchronize, opened, reopened] + +jobs: + check-first-commit: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Check for web UI first commit + run: | + PR_NUMBER=$(jq --raw-output .pull_request.number "$GITHUB_EVENT_PATH") + COMMITS_URL="https://api.github.com/repos/$GITHUB_REPOSITORY/pulls/$PR_NUMBER/commits" + + first_commit=$(curl --header "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" "$COMMITS_URL" | jq '.[0]') + + web_ui_commit=$(echo "$first_commit" | jq 'select(.commit.message | test("Update"))') + + if [ -n "$web_ui_commit" ]; then + echo "The first commit in the pull request was created via the GitHub web UI." + exit 1 + fi