-
Notifications
You must be signed in to change notification settings - Fork 1
83 lines (73 loc) · 2.25 KB
/
diff.yaml
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
name: Diff
on:
pull_request:
jobs:
diff:
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: Checkout base
uses: actions/checkout@v4
with:
ref: '${{ github.event.pull_request.base.sha }}'
path: base
- name: Checkout head
uses: actions/checkout@v4
with:
path: head
# https://stackoverflow.com/a/73596568
- name: Setup to skip ksops decryption
run: sudo ln -s /bin/true /usr/local/bin/ksops
- name: Install dyff
run: |
# TODO: Use upstream once https://github.com/homeport/dyff/pull/409 is merged?
# curl -s -L https://git.io/JYfAY | bash
curl -s -L https://git.io/JYfAY | ORG=motoki317 REPO=dyff bash
- name: Build base
working-directory: ./base
run: ./build.sh
- name: Build head
working-directory: ./head
run: ./build.sh
- name: Diff
id: diff
run: |
# With console colors
./head/diff.sh \
base/.built \
head/.built \
--omit-header
# Plaintext
./head/diff.sh \
base/.built \
head/.built \
--omit-header --output github \
> diff.txt
echo 'diff<<EOF' >> $GITHUB_OUTPUT
cat diff.txt >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
echo '### Diff' >> $GITHUB_STEP_SUMMARY
echo '```diff' >> $GITHUB_STEP_SUMMARY
cat diff.txt >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
- if: ${{ steps.diff.outputs.diff != '' }}
name: Add comment
uses: mshick/add-pr-comment@v2
with:
message-id: "${{ github.event.pull_request.number }}"
message-failure: Diff was not successful
message: |
### Diff
```diff
${{ steps.diff.outputs.diff }}
```
- if: ${{ steps.diff.outputs.diff == '' }}
name: Add comment
uses: mshick/add-pr-comment@v2
with:
message-id: "${{ github.event.pull_request.number }}"
message-failure: Diff was not successful
message: |
### Diff
No diff detected!