summary refs log tree commit diff
path: root/.github/workflows/dependabot_changelog.yml
blob: dcad8d4a249e7dec7119cda519bacbab4074b4c4 (plain) (blame)
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
name: Write changelog for dependabot PR
on:
  pull_request:
    types:
      - opened

permissions:
  # Needed to be able to push the commit. See 
  #     https://docs.github.com/en/code-security/dependabot/working-with-dependabot/automating-dependabot-with-github-actions#enable-auto-merge-on-a-pull-request
  # for a similar example
  contents: write
  # The pull_requests "synchronize" event doesn't seem to fire with just `contents: write`, so
  # CI doesn't run with the new changelog. Maybe `pull_requests: write` will fix this?
  pull_requests: write

jobs:
  add-changelog:
    runs-on: 'ubuntu-latest'
    if: ${{ github.actor == 'dependabot[bot]' }}
    steps:
      - uses: actions/checkout@v3
        with:
          ref: ${{ github.event.pull_request.head.ref }}
      - name: Write, commit and push changelog
        run: |
          echo "${{ github.event.pull_request.title }}." > "changelog.d/${{ github.event.pull_request.number }}".misc
          git add changelog.d
          git config user.email "github-actions[bot]@users.noreply.github.com"
          git config user.name "GitHub Actions"
          git commit -m "Changelog"
          git push
        shell: bash
  # THIS WORKFLOW HAS VARIOUS WRITE PERMISSIONS---do not add other jobs here unless they
  # are sufficiently locked down to dependabot only as above.