@@ -4,22 +4,90 @@ name: Changelog Entry
4
4
5
5
on :
6
6
pull_request :
7
- types : [opened, synchronize, labeled]
7
+ types : [opened, synchronize, labeled, reopened ]
8
8
# Runs on PRs to main and all release branches
9
9
branches :
10
10
- main
11
11
12
+ permissions :
13
+ pull-requests : write
14
+ contents : write
15
+
12
16
jobs :
17
+ generate-release-note :
18
+ if : github.actor == 'dependabot[bot]'
19
+ runs-on : ubuntu-latest
20
+ steps :
21
+ - name : Checkout
22
+ uses : actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
23
+ with :
24
+ fetch-depth : 0
25
+ ref : ${{ github.event.pull_request.head.ref }}
26
+ - name : Generate .changelog entry
27
+ env :
28
+ PR_NUMBER : ${{ github.event.pull_request.number }}
29
+ PR_TITLE : ${{ github.event.pull_request.title }}
30
+ PR_BODY : ${{ github.event.pull_request.body_text }}
31
+ run : |
32
+ FIRST_COMMIT=$(git log -10 --pretty=format:%H origin/main..HEAD | tail -1)
33
+ FIRST_COMMIT_BODY=$(git log -1 --pretty=format:%B $FIRST_COMMIT)
34
+ mkdir -p .changelog
35
+ echo "backticksrelease-note:enhancement" > .changelog/$PR_NUMBER.txt
36
+ echo "ci/dependabot: $PR_TITLE" >> .changelog/$PR_NUMBER.txt
37
+ echo "" >> .changelog/$PR_NUMBER.txt
38
+ echo "$FIRST_COMMIT_BODY" >> .changelog/$PR_NUMBER.txt
39
+ echo "backticks" >> .changelog/$PR_NUMBER.txt
40
+ sed -i 's/backticks/```/g' .changelog/$PR_NUMBER.txt
41
+ - name : Commit and Push
42
+ env :
43
+ GIT_USER : ${{ secrets.GIT_USER }}
44
+ GIT_TOKEN : ${{ secrets.GIT_TOKEN }}
45
+ run : |
46
+ git branch
47
+ echo "---"
48
+ git log -1
49
+ echo "---"
50
+ git config --local user.email "dependabot[bot]@users.noreply.github.com"
51
+ git config --local user.name "dependabot[bot]"
52
+ git add .changelog
53
+ git commit --amend --no-edit
54
+ echo "---"
55
+ git log -1
56
+ git push --force "https://x-access-token:$GITHUB_TOKEN@github.com/${{ github.repository }}.git" HEAD:${{ github.event.pull_request.head.ref }}
13
57
# checks that a .changelog entry is present for a PR
58
+ changelog-check-dpbot :
59
+ runs-on : ubuntu-latest
60
+ needs : [generate-release-note]
61
+ steps :
62
+ - uses : actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
63
+ with :
64
+ # ref: ${{ github.event.pull_request.head.sha }}
65
+ ref : ${{ github.event.pull_request.head.ref }}
66
+ fetch-depth : 0 # by default the checkout action doesn't checkout all branches
67
+ - name : Check for changelog entry in diff
68
+ run : |
69
+ # check if there is a diff in the .changelog directory
70
+ changelog_files=$(git --no-pager diff --name-only HEAD "$(git merge-base HEAD "origin/${{ github.event.pull_request.base.ref }}")" -- .changelog/${{ github.event.pull_request.number }}.txt)
71
+
72
+ # If we do not find a file in .changelog/, we fail the check
73
+ if [ -z "$changelog_files" ]; then
74
+ # Fail status check when no .changelog entry was found on the PR
75
+ echo "Did not find a .changelog entry and the 'pr/no-changelog' label was not applied."
76
+ exit 1
77
+ else
78
+ echo "Found .changelog entry in PR!"
79
+ fi
80
+ - uses : ./.github/workflows/k8s.yml
81
+ name : Trigger k8s tests
14
82
changelog-check :
15
83
# If there a `pr/no-changelog` label we ignore this check
16
- if : " !contains(github.event.pull_request.labels.*.name, 'pr/no-changelog') || github.event.pull_request.user.login == 'dependabot' "
84
+ if : " !contains(github.event.pull_request.labels.*.name, 'pr/no-changelog')"
17
85
runs-on : ubuntu-latest
18
-
19
86
steps :
20
87
- uses : actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
21
88
with :
22
- ref : ${{ github.event.pull_request.head.sha }}
89
+ # ref: ${{ github.event.pull_request.head.sha }}
90
+ ref : ${{ github.event.pull_request.head.ref }}
23
91
fetch-depth : 0 # by default the checkout action doesn't checkout all branches
24
92
- name : Check for changelog entry in diff
25
93
run : |
0 commit comments