-
Notifications
You must be signed in to change notification settings - Fork 5
58 lines (53 loc) · 1.91 KB
/
changie-gen.yml
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
name: Changie Gen
on:
workflow_run:
workflows: [Dependabot Labels]
types:
- completed
jobs:
generate-changelog:
env:
MAIN_BRANCH: ${{ github.event.workflow_run.pull_requests[0].base.ref }}
PR_BRANCH: ${{ github.event.workflow_run.pull_requests[0].head.ref }}
runs-on: ubuntu-latest
# NOTE: "github.event.workflow_run.conclusion" check needed within "steps"
steps:
- name: Checkout branch that Dependabot labeled
if: github.event.workflow_run.conclusion == 'success'
uses: actions/checkout@v4
with:
ref: ${{ env.PR_BRANCH }}
token: ${{ secrets.ORG_GITHUB_TOKEN }}
- name: Check if changelog file exists already
if: github.event.workflow_run.conclusion == 'success'
shell: bash
id: changelog_check
run: |
git fetch origin ${{ env.MAIN_BRANCH }}
if [[ -n $(git diff --name-only main -- .changes/unreleased/*.yaml) ]]; then
echo "exists=true" >> $GITHUB_OUTPUT
echo "Changelog already exists for this PR, skip creating a new one"
else
echo "exists=false" >> $GITHUB_OUTPUT
echo "No changelog exists for this PR, creating a new one"
fi
- name: Create changie log
if: >-
github.event.workflow_run.conclusion == 'success' &&
steps.changelog_check.outputs.exists == 'false'
uses: miniscruff/changie-action@v2
with:
version: latest
args: new --kind Dependency --body "${{ github.event.workflow_run.display_title }}"
- name: Commit & Push changes
if: >-
github.event.workflow_run.conclusion == 'success' &&
steps.changelog_check.outputs.exists == 'false'
shell: bash
run: |
git config user.name "OpsLevel Bots"
git config user.email "[email protected]"
git pull
git add .
git commit -m "Add automated changelog yaml from template"
git push