-
Notifications
You must be signed in to change notification settings - Fork 368
58 lines (49 loc) · 1.7 KB
/
diff-pr.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
name: Detect differences (PR only)
on:
pull_request:
types: [opened, synchronize, reopened]
jobs:
diff:
runs-on: ubuntu-latest
env:
DOTNET_NOLOGO: true
permissions:
pull-requests: write
steps:
- uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 100
# The GitHub checkout action leaves the repo in a slightly awkward
# state. This tidies it up.
- name: Set up git branches
run: |
git checkout -b pr-head
git checkout -b main ${{ github.event.pull_request.base.sha }}
git checkout pr-head
- name: Setup .NET 6.0
uses: actions/setup-dotnet@v4
with:
dotnet-version: 6.0.x
- name: Detect PR changes
env:
ALLOW_BREAKING_CHANGES: ${{contains(github.event.pull_request.labels.*.name, 'allow breaking changes')}}
run: |
if [[ $ALLOW_BREAKING_CHANGES == "true" ]]
then
SCRIPT_OPTION=--allow-breaking-changes
fi
# Run the diff, recording the results
echo "**Pull request diff results**" >> diff.txt
set -o pipefail
./detect-pr-changes.sh $SCRIPT_OPTION 2>&1 | tee -a diff.txt
set +o pipefail
# The purpose of (success() || failure()) in the condition is to
# make sure we post a comment on both success and failure, but *not*
# if the job is cancelled.
- name: Post diff as a comment for branches on target fork
if: (success() || failure()) && github.event.pull_request.head.repo.full_name == github.repository
run: |
./prepare-release.sh add-pr-comment diff.txt \
${{github.event.pull_request.number }} \
${{secrets.GITHUB_TOKEN}}