From c9911f91ae02473f4c4616ff2c69a14c8beb5b01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Domen=20Ko=C5=BEar?= Date: Mon, 19 Apr 2021 13:35:15 +0200 Subject: [PATCH 1/3] Add a warning comment on commits that violate https://github.com/NixOS/nixpkgs/issues/118661 --- .github/workflows/direct-push.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .github/workflows/direct-push.yml diff --git a/.github/workflows/direct-push.yml b/.github/workflows/direct-push.yml new file mode 100644 index 000000000000..db9da761760f --- /dev/null +++ b/.github/workflows/direct-push.yml @@ -0,0 +1,28 @@ +name: "Direct Push Warning" +on: + push: + branches: + - master + - release-** +jobs: + build: + runs-on: ubuntu-latest + env: + GITHUB_SHA: ${{ github.sha }} + GITHUB_REPOSITORY: ${{ github.repository }} + steps: + - name: Check if commit is a merge commit + id: ismerge + run: | + ISMERGE=$(curl -H 'Accept: application/vnd.github.groot-preview+json' -H "authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/${{ env.GITHUB_REPOSITORY }}/commits/${{ env.GITHUB_SHA }}/pulls | jq -r '.[] | select(.merge_commit_sha == "${{ env.GITHUB_SHA }}") | any') + echo "::set-output name=ismerge::$ISMERGE" + - name: Warn if the commit was a direct push + if: steps.ismerge.outputs.ismerge != 'true' + uses: peter-evans/commit-comment@v1 + with: + body: | + @${{ github.actor }} pushed a commit directly to master/release branch + instead of going through a Pull Request. + + That's highly discouraged beyond the few exceptions listed + on https://github.com/NixOS/nixpkgs/issues/118661. From 932ffcd08d82b11a507c3a5d93f950f6036765c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Domen=20Ko=C5=BEar?= Date: Mon, 19 Apr 2021 14:06:54 +0200 Subject: [PATCH 2/3] Update .github/workflows/direct-push.yml Co-authored-by: Alyssa Ross --- .github/workflows/direct-push.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/direct-push.yml b/.github/workflows/direct-push.yml index db9da761760f..554cffa3a998 100644 --- a/.github/workflows/direct-push.yml +++ b/.github/workflows/direct-push.yml @@ -21,7 +21,7 @@ jobs: uses: peter-evans/commit-comment@v1 with: body: | - @${{ github.actor }} pushed a commit directly to master/release branch + @${{ github.actor }}, you pushed a commit directly to master/release branch instead of going through a Pull Request. That's highly discouraged beyond the few exceptions listed From 436161a2b83cf747af18389d0f0520488b449c4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Domen=20Ko=C5=BEar?= Date: Tue, 20 Apr 2021 08:13:07 +0100 Subject: [PATCH 3/3] Update .github/workflows/direct-push.yml Co-authored-by: zowoq <59103226+zowoq@users.noreply.github.com> --- .github/workflows/direct-push.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/direct-push.yml b/.github/workflows/direct-push.yml index 554cffa3a998..6177004295ff 100644 --- a/.github/workflows/direct-push.yml +++ b/.github/workflows/direct-push.yml @@ -7,6 +7,7 @@ on: jobs: build: runs-on: ubuntu-latest + if: github.repository_owner == 'NixOS' env: GITHUB_SHA: ${{ github.sha }} GITHUB_REPOSITORY: ${{ github.repository }} @@ -25,4 +26,4 @@ jobs: instead of going through a Pull Request. That's highly discouraged beyond the few exceptions listed - on https://github.com/NixOS/nixpkgs/issues/118661. + on https://github.com/NixOS/nixpkgs/issues/118661