-
Notifications
You must be signed in to change notification settings - Fork 4
72 lines (65 loc) · 2.52 KB
/
changie-gen.yaml
File metadata and controls
72 lines (65 loc) · 2.52 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
name: Changie Gen
on:
pull_request:
# catch when the PR is opened with the label or when the label is added
types: [labeled]
permissions:
contents: write
pull-requests: read
jobs:
generate-changelog:
if: contains(github.event.pull_request.labels.*.name, 'dependencies')
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@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
with:
ref: ${{ env.PR_BRANCH }}
token: ${{ secrets.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: Setup Go
if: >-
github.event.workflow_run.conclusion == 'success' &&
steps.changelog_check.outputs.exists == 'false'
uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5
with:
go-version-file: src/go.mod
- name: Create changie log
if: >-
github.event.workflow_run.conclusion == 'success' &&
steps.changelog_check.outputs.exists == 'false'
env:
PR_TITLE: ${{ github.event.workflow_run.display_title }}
shell: bash
run: |
CHANGIE=$(cd src && go tool -n changie)
"$CHANGIE" new --kind Dependency --body "$PR_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 "bots@opslevel.com"
git pull
git add .
git commit -m "Add automated changelog yaml from template"
git push