@@ -4,22 +4,96 @@ 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+ PR_NUMBER : ${{ github.event.pull_request.number }}
46+ run : |
47+ echo $GIT_USER
48+ echo "---x"
49+ echo $GIT_TOKEN
50+ echo "x---"
51+ echo $GH_TOKEN
52+ echo "x---x"
53+ git branch
54+ echo "---"
55+ git log -1
56+ echo "---"
57+ git config --local user.email "dependabot[bot]@users.noreply.github.com"
58+ git config --local user.name "dependabot[bot]"
59+ git add .changelog
60+ # git commit --amend --no-edit
61+ echo "---"
62+ git log -1
63+ git commit -m "Add .changelog/$PR_NUMBER.txt"
64+ git push
65+ # git push --force "https://x-access-token:[email protected] /${{ github.repository }}.git" HEAD:${{ github.event.pull_request.head.ref }} 66+ # echo '{"pull_request_number": "${{ github.event.pull_request.number }}"}' | gh workflow run k8s.yml --ref ${{ github.event.pull_request.head.ref }} --json -
1367 # checks that a .changelog entry is present for a PR
68+ changelog-check-dpbot :
69+ runs-on : ubuntu-latest
70+ needs : [generate-release-note]
71+ steps :
72+ - uses : actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
73+ with :
74+ # ref: ${{ github.event.pull_request.head.sha }}
75+ ref : ${{ github.event.pull_request.head.ref }}
76+ fetch-depth : 0 # by default the checkout action doesn't checkout all branches
77+ - name : Check for changelog entry in diff
78+ run : |
79+ # check if there is a diff in the .changelog directory
80+ CM=$(git log -1 --format='%H')
81+ echo $CM
82+ if [ -z "$(git diff --name-only --diff-filter=A ${{ github.event.pull_request.base.sha }} $CM | grep ".changelog/${{ github.event.pull_request.number }}.txt")" ]; then
83+ echo "Did not find a .changelog entry and the 'pr/no-changelog' label was not applied."
84+ exit 1
85+ else
86+ echo "Found .changelog entry in PR!"
87+ fi
1488 changelog-check :
1589 # 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'"
90+ if : " !contains(github.event.pull_request.labels.*.name, 'pr/no-changelog') && github.actor != 'dependabot[bot] '"
1791 runs-on : ubuntu-latest
18-
1992 steps :
2093 - uses : actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
2194 with :
22- ref : ${{ github.event.pull_request.head.sha }}
95+ # ref: ${{ github.event.pull_request.head.sha }}
96+ ref : ${{ github.event.pull_request.head.ref }}
2397 fetch-depth : 0 # by default the checkout action doesn't checkout all branches
2498 - name : Check for changelog entry in diff
2599 run : |
0 commit comments