@@ -4,22 +4,95 @@ name: Changelog Entry
44
55on :
66 pull_request :
7- types : [opened, synchronize, labeled]
7+ types : [opened, synchronize, labeled, reopened ]
88 # Runs on PRs to main and all release branches
99 branches :
1010 - main
1111
12+ permissions :
13+ pull-requests : write
14+ contents : write
15+
1216jobs :
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_TOKEN : ${{ secrets.GITHUB_TOKEN }}
44+ GH_TOKEN : ${{ secrets.GCR_SK8L_CR_PAT }}
45+ run : |
46+ echo $GIT_USER
47+ echo "---x"
48+ echo $GIT_TOKEN
49+ echo "x---"
50+ echo $GH_TOKEN
51+ echo "x---x"
52+ git branch
53+ echo "---"
54+ git log -1
55+ echo "---"
56+ git config --local user.email "dependabot[bot]@users.noreply.github.com"
57+ git config --local user.name "dependabot[bot]"
58+ git add .changelog
59+ git commit --amend --no-edit
60+ echo "---"
61+ git log -1
62+ git push --force "https://x-access-token:$GITHUB_TOKEN@github.com/${{ github.repository }}.git" HEAD:${{ github.event.pull_request.head.ref }}
63+ # echo '{"pull_request_number": "${{ github.event.pull_request.number }}"}' | gh workflow run k8s.yml --ref ${{ github.event.pull_request.head.ref }} --json -
1364 # checks that a .changelog entry is present for a PR
65+ changelog-check-dpbot :
66+ runs-on : ubuntu-latest
67+ needs : [generate-release-note]
68+ steps :
69+ - uses : actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
70+ with :
71+ # ref: ${{ github.event.pull_request.head.sha }}
72+ ref : ${{ github.event.pull_request.head.ref }}
73+ fetch-depth : 0 # by default the checkout action doesn't checkout all branches
74+ - name : Check for changelog entry in diff
75+ run : |
76+ # check if there is a diff in the .changelog directory
77+ 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)
78+
79+ # If we do not find a file in .changelog/, we fail the check
80+ if [ -z "$changelog_files" ]; then
81+ # Fail status check when no .changelog entry was found on the PR
82+ echo "Did not find a .changelog entry and the 'pr/no-changelog' label was not applied."
83+ exit 1
84+ else
85+ echo "Found .changelog entry in PR!"
86+ fi
1487 changelog-check :
1588 # 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'"
89+ if : " !contains(github.event.pull_request.labels.*.name, 'pr/no-changelog') && github.actor != 'dependabot[bot] '"
1790 runs-on : ubuntu-latest
18-
1991 steps :
2092 - uses : actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
2193 with :
22- ref : ${{ github.event.pull_request.head.sha }}
94+ # ref: ${{ github.event.pull_request.head.sha }}
95+ ref : ${{ github.event.pull_request.head.ref }}
2396 fetch-depth : 0 # by default the checkout action doesn't checkout all branches
2497 - name : Check for changelog entry in diff
2598 run : |
0 commit comments