Skip to content

Commit 7ed9341

Browse files
authored
Update code-formatting.yml
1 parent 64d5993 commit 7ed9341

1 file changed

Lines changed: 14 additions & 12 deletions

File tree

.github/workflows/code-formatting.yml

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Check PR with clang-format
22

3-
on: [pull_request]
3+
on: [pull_request_target]
44

55
jobs:
66
build:
@@ -9,26 +9,28 @@ jobs:
99
steps:
1010
- uses: actions/checkout@v2
1111
with:
12-
ref: ${{ github.event.pull_request.head.sha }}
12+
ref: ${{ github.event.pull_request_target.head.sha }}
1313
- name: Run clang format
1414
id: clang_format
1515
env:
1616
ALIBUILD_GITHUB_TOKEN: ${{secrets.ALIBUILD_GITHUB_TOKEN}}
1717
run: |
1818
set -x
1919
# We need to fetch the other commit.
20-
git fetch --depth=1 origin ${{ github.event.pull_request.base.ref }}
20+
git fetch --depth=1 origin ${{ github.event.pull_request_target.base.ref }}
2121
2222
# We create a new branch which we will use for the eventual PR.
2323
git config --global user.email "alibuild@cern.ch"
2424
git config --global user.name "ALICE Action Bot"
25-
git checkout -b alibot-cleanup-${{ github.event.pull_request.number }} ${{ github.event.pull_request.head.sha }}
25+
git checkout -b alibot-cleanup-${{ github.event.pull_request_target.number }} ${{ github.event.pull_request_target.head.sha }}
2626
27-
BASE_COMMIT=${{ github.event.pull_request.base.sha }}
28-
echo "Running clang-format-8 against branch ${{ github.event.pull_request.base.ref }} , with hash ${{ github.event.pull_request.base.sha }}"
27+
BASE_COMMIT=${{ github.event.pull_request_target.base.sha }}
28+
echo "Running clang-format-8 against branch ${{ github.event.pull_request_target.base.ref }} , with hash ${{ github.event.pull_request_target.base.sha }}"
2929
COMMIT_FILES=$(git diff --name-only $BASE_COMMIT | grep -ivE 'LinkDef|Utilities/PCG/')
3030
RESULT_OUTPUT="$(git-clang-format-8 --commit $BASE_COMMIT --diff --binary `which clang-format-8` $COMMIT_FILES)"
31-
git-clang-format-8 --commit $BASE_COMMIT --diff --binary `which clang-format-8` $COMMIT_FILES | patch -p1
31+
git-clang-format-8 --commit $BASE_COMMIT \
32+
--diff --binary `which \
33+
clang-format-8` $COMMIT_FILES | patch -p1
3234
3335
for x in $COMMIT_FILES; do
3436
case $x in
@@ -49,7 +51,7 @@ jobs:
4951
if [ "$RESULT_OUTPUT" == "no modified files to format" ] \
5052
|| [ "$RESULT_OUTPUT" == "clang-format did not modify any files" ] ; then
5153
echo "clang-format passed."
52-
git push --set-upstream origin :alibot-cleanup-${{ github.event.pull_request.number }} -f || true
54+
git push --set-upstream origin :alibot-cleanup-${{ github.event.pull_request_target.number }} -f || true
5355
echo ::set-output name=clean::true
5456
else
5557
echo "clang-format failed."
@@ -61,17 +63,17 @@ jobs:
6163
git show | cat
6264
echo ${{ secrets.ALIBUILD_GITHUB_TOKEN }} | wc
6365
echo $ALIBUILD_GITHUB_TOKEN | wc
64-
git push --set-upstream https://alibuild:$ALIBUILD_GITHUB_TOKEN@github.com/${{ github.event.pull_request.user.login }}/AliceO2.git HEAD:refs/heads/alibot-cleanup-${{ github.event.pull_request.number }} -f
66+
git push --set-upstream https://alibuild:$ALIBUILD_GITHUB_TOKEN@github.com/alibuild/AliceO2.git HEAD:refs/heads/alibot-cleanup-${{ github.event.pull_request_target.number }} -f
6567
echo ::set-output name=clean::false
6668
fi
6769
6870
- name: pull-request
6971
uses: alisw/pull-request@master
7072
with:
71-
source_branch: '${{ github.event.pull_request.user.login }}:alibot-cleanup-${{ github.event.pull_request.number }}'
72-
destination_branch: '${{ github.event.pull_request.user.login }}:${{ github.event.pull_request.head.ref }}'
73+
source_branch: '${{ github.event.pull_request_target.user.login }}:alibot-cleanup-${{ github.event.pull_request_target.number }}'
74+
destination_branch: '${{ github.event.pull_request_target.user.login }}:${{ github.event.pull_request_target.head.ref }}'
7375
github_token: ${{ secrets.GITHUB_TOKEN }}
74-
pr_title: "Please consider the following formatting changes to #${{ github.event.pull_request.number }}"
76+
pr_title: "Please consider the following formatting changes to #${{ github.event.pull_request_target.number }}"
7577
pr_body: "Please consider the following formatting changes"
7678
continue-on-error: true # We do not create PRs if the branch is not there.
7779

0 commit comments

Comments
 (0)