about summary refs log tree commit diff
path: root/.github
diff options
context:
space:
mode:
authorDomen Kožar <domen@dev.si>2021-04-19 13:35:15 +0200
committerDomen Kožar <domen@dev.si>2021-04-19 13:51:19 +0200
commitc9911f91ae02473f4c4616ff2c69a14c8beb5b01 (patch)
tree614d39ed89f93584e9c7d781f659198ceedbc53b /.github
parentabf3a8af7c387f8392c92501c81080655c21166e (diff)
downloadnixlib-c9911f91ae02473f4c4616ff2c69a14c8beb5b01.tar
nixlib-c9911f91ae02473f4c4616ff2c69a14c8beb5b01.tar.gz
nixlib-c9911f91ae02473f4c4616ff2c69a14c8beb5b01.tar.bz2
nixlib-c9911f91ae02473f4c4616ff2c69a14c8beb5b01.tar.lz
nixlib-c9911f91ae02473f4c4616ff2c69a14c8beb5b01.tar.xz
nixlib-c9911f91ae02473f4c4616ff2c69a14c8beb5b01.tar.zst
nixlib-c9911f91ae02473f4c4616ff2c69a14c8beb5b01.zip
Add a warning comment on commits that violate https://github.com/NixOS/nixpkgs/issues/118661
Diffstat (limited to '.github')
-rw-r--r--.github/workflows/direct-push.yml28
1 files changed, 28 insertions, 0 deletions
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.