11name : Changie Gen
22
33on :
4- workflow_run :
5- workflows : [Dependabot Labels]
6- types :
7- - completed
4+ pull_request :
5+ # catch when the PR is opened with the label or when the label is added
6+ types : [labeled]
7+
8+ permissions :
9+ contents : write
10+ pull-requests : read
811
912jobs :
1013 generate-changelog :
14+ if : contains(github.event.pull_request.labels.*.name, 'dependencies')
1115 env :
1216 MAIN_BRANCH : ${{ github.event.workflow_run.pull_requests[0].base.ref }}
1317 PR_BRANCH : ${{ github.event.workflow_run.pull_requests[0].head.ref }}
1418 runs-on : ubuntu-latest
1519 # NOTE: "github.event.workflow_run.conclusion" check needed within "steps"
1620 steps :
17- - name : Checkout branch that Dependabot labeled
18- if : github.event.workflow_run.conclusion == 'success'
19- uses : actions/checkout@v5
20- with :
21- ref : ${{ env.PR_BRANCH }}
22- token : ${{ secrets.ORG_GITHUB_TOKEN }}
21+ - name : Checkout branch that Dependabot labeled
22+ if : github.event.workflow_run.conclusion == 'success'
23+ uses : actions/checkout@v5
24+ with :
25+ ref : ${{ env.PR_BRANCH }}
26+ token : ${{ secrets.GITHUB_TOKEN }}
2327
24- - name : Check if changelog file exists already
25- if : github.event.workflow_run.conclusion == 'success'
26- shell : bash
27- id : changelog_check
28- run : |
29- git fetch origin ${{ env.MAIN_BRANCH }}
30- if [[ -n $(git diff --name-only main -- .changes/unreleased/*.yaml) ]]; then
31- echo "exists=true" >> $GITHUB_OUTPUT
32- echo "Changelog already exists for this PR, skip creating a new one"
33- else
34- echo "exists=false" >> $GITHUB_OUTPUT
35- echo "No changelog exists for this PR, creating a new one"
36- fi
28+ - name : Check if changelog file exists already
29+ if : github.event.workflow_run.conclusion == 'success'
30+ shell : bash
31+ id : changelog_check
32+ run : |
33+ git fetch origin ${{ env.MAIN_BRANCH }}
34+ if [[ -n $(git diff --name-only main -- .changes/unreleased/*.yaml) ]]; then
35+ echo "exists=true" >> $GITHUB_OUTPUT
36+ echo "Changelog already exists for this PR, skip creating a new one"
37+ else
38+ echo "exists=false" >> $GITHUB_OUTPUT
39+ echo "No changelog exists for this PR, creating a new one"
40+ fi
3741
38- - name : Create changie log
39- if : >-
40- github.event.workflow_run.conclusion == 'success' &&
41- steps.changelog_check.outputs.exists == 'false'
42- uses : miniscruff/changie-action@v2
43- with :
44- version : latest
45- args : new --kind Dependency --body "${{ github.event.workflow_run.display_title }}"
42+ - name : Create changie log
43+ if : >-
44+ github.event.workflow_run.conclusion == 'success' &&
45+ steps.changelog_check.outputs.exists == 'false'
46+ uses : miniscruff/changie-action@v2
47+ with :
48+ version : latest
49+ args : new --kind Dependency --body "${{ github.event.workflow_run.display_title }}"
4650
47- - name : Commit & Push changes
48- if : github.event.workflow_run.conclusion == 'success' && steps.changelog_check.outputs.exists == 'false'
49- shell : bash
50- run : |
51- git config user.name "OpsLevel Bots"
52- git config user.email "bots@opslevel.com"
53- git pull
54- git add .
55- git commit -m "Add automated changelog yaml from template"
56- git push
51+ - name : Commit & Push changes
52+ if : >-
53+ github.event.workflow_run.conclusion == 'success' &&
54+ steps.changelog_check.outputs.exists == 'false'
55+ shell : bash
56+ run : |
57+ git config user.name "OpsLevel Bots"
58+ git config user.email "bots@opslevel.com"
59+ git pull
60+ git add .
61+ git commit -m "Add automated changelog yaml from template"
62+ git push
0 commit comments