Skip to content

Commit 4a55e79

Browse files
authored
Simplify GitHub workflows for pull requests (#52)
1 parent 717ec81 commit 4a55e79

File tree

3 files changed

+46
-44
lines changed

3 files changed

+46
-44
lines changed

.github/workflows/pre-commit-ci.yml

Lines changed: 0 additions & 38 deletions
This file was deleted.

.github/workflows/pull_request.yml

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,59 @@
11
---
22

3-
name: PR
4-
on:
3+
name: Pull requests
4+
on: # yamllint disable-line rule:truthy
55
pull_request:
66
types: [opened, synchronize, reopened, ready_for_review, labeled, unlabeled]
77

88
jobs:
9-
# Enforces the update of a changelog file on every pull request
9+
update-changelog:
10+
runs-on: ubuntu-latest
11+
name: "Pre-commit CI CHANGELOG auto-update"
12+
if: >
13+
(github.event.pull_request.title == '[pre-commit.ci] pre-commit autoupdate') &&
14+
(github.event.action == 'opened')
15+
steps:
16+
- uses: actions/checkout@v3
17+
with:
18+
ref: ${{ github.event.pull_request.head.ref }}
19+
fetch-depth: 0
20+
token: ${{ secrets.PRE_COMMIT_CI_CHANGELOG }}
21+
22+
- name: Setup Python
23+
uses: actions/setup-python@v3
24+
with:
25+
python-version: '3.11'
26+
cache: 'pip'
27+
cache-dependency-path: '**/setup.cfg'
28+
29+
- name: Install dependencies
30+
run: |
31+
python3 -m pip install 'git+https://github.com/Takishima/pre-commit-changelog-auto-update@v1.0.0'
32+
33+
- name: Run Python script
34+
run: |
35+
python3 -m update_changelog --pr-body "${{ github.event.pull_request.body }}"
36+
37+
- name: Commit changes
38+
id: commit
39+
uses: EndBug/add-and-commit@v9
40+
with:
41+
author_name: github-actions[bot]
42+
author_email: noreply@github.com
43+
message: Update CHANGELOG
44+
1045
changelog:
46+
needs: update-changelog
1147
runs-on: ubuntu-latest
48+
name: CHANGELOG enforcer
49+
if: '!cancelled()'
1250
steps:
1351
- uses: actions/checkout@v3
52+
with:
53+
ref: ${{ github.event.pull_request.head.ref }}
54+
fetch-depth: 0
1455

15-
- id: changelog-enforcer
16-
uses: dangoslen/changelog-enforcer@v3
56+
- uses: dangoslen/changelog-enforcer@v3
1757
with:
1858
changeLogPath: 'CHANGELOG.md'
1959
skipLabels: 'Skip-Changelog'

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1515

1616
- Replace most Python pre-commit hooks with [ruff](https://beta.ruff.rs/docs/)
1717
- Update release drafting GitHub workflow
18-
- Add workflow to automatically update CHANGELOG when pre-commit.ci updates happen
18+
- Modify pull requests workflow to automatically update CHANGELOG file if it was created by pre-commit.ci
1919
- Added some more pre-commit hooks:
2020
- doc8
2121
- codespell

0 commit comments

Comments
 (0)