-
Notifications
You must be signed in to change notification settings - Fork 9
50 lines (48 loc) · 1.98 KB
/
ci-dependabot.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
# NOTE: This name appears in GitHub's Checks API and in workflow's status badge.
name: ci-dependabot
# Trigger the workflow when:
on:
# When a pull request event occurs for a pull request against one of the
# matched branches.
pull_request:
branches: [master]
jobs:
add-changelog:
# NOTE: This name appears in GitHub's Checks API.
name: add-changelog
# Trigger job only for dependency update bot.
if: github.actor == 'dependabot[bot]'
runs-on: ubuntu-latest
# Permissions needed to update PR.
permissions:
# Enable creating and updating files.
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
# Needed for correct git commit --amend.
fetch-depth: 0
# Checkout pull request HEAD commit instead of merge commit.
ref: ${{ github.event.pull_request.head.sha }}
- name: Create Change Log file
env:
# There's no support for escaping this for use in a shell command.
# GitHub's recommendation is to pass it through the environment.
# https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable
TITLE: ${{ github.event.pull_request.title }}
FILE_NAME: .changelog/${{ github.event.pull_request.number }}.internal.md
run: |
echo "$TITLE" > "$FILE_NAME"
- name: Commit Change Log file
env:
FILE_NAME: .changelog/${{ github.event.pull_request.number }}.internal.md
run: |
# Set git user email and name to match author of the last commit.
git config --local user.email "$(git log --pretty='%ae' -1)"
git config --local user.name "$(git log --pretty=format:'%an' -1)"
git add "$FILE_NAME"
git commit --amend --no-edit
- name: Push changes back to branch
run: |
git push --force-with-lease origin "HEAD:refs/heads/$GITHUB_HEAD_REF"