Skip to content

Commit

Permalink
feat: add changelog and pr mgmt
Browse files Browse the repository at this point in the history
  • Loading branch information
jimbrig committed Feb 23, 2024
1 parent 4287de5 commit c9d102e
Show file tree
Hide file tree
Showing 4 changed files with 175 additions and 0 deletions.
100 changes: 100 additions & 0 deletions .github/cliff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# configuration file for git-cliff (0.1.0)

[changelog]

# remove the leading and trailing whitespace from the template
trim = true

# header
header = """
# Changelog\n
> All notable changes to this project will be documented in this file. The format is based on
[Keep a Changelog](http://keepachangelog.com/) and this project adheres to
[Semantic Versioning](http://semver.org/).\n
"""

# body - see https://tera.netlify.app/docs/#introduction
body = """
{% if version %}\
## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }}
{% else %}\
## [Unreleased]
{% endif %}\
{% for group, commits in commits | group_by(attribute="group") %}
### {{ group | upper_first }}
{% for commit in commits %}
- {% if commit.breaking %}[**breaking**] {% endif %}{{ commit.message | upper_first }}\
{% endfor %}
{% endfor %}\n
"""

# footer
footer = """
***
*Changelog generated by [git-cliff](https://github.com/orhun/git-cliff).*
***
"""

# commits
[git]
conventional_commits = true
filter_unconventional = true
filter_commits = true
tag_pattern = "v[0-9]*"
skip_tags = "v0.0.0.9999" # "v0.1.0-beta.1"
ignore_tags = ""
date_order = true
topo_order = true
sort_commits = "newest" # "oldest"
split_commits = false
protect_breaking_commits = true
# limit_commits = 42
commit_preprocessors = [
{ pattern = '\((\w+\s)?#([0-9]+)\)', replace = "([#${2}](https://github.com/orhun/git-cliff/issues/${2}))" },
]
commit_parsers = [
{ message = "^feat", group = "Features" },
{ message = "^fix", group = "Bug Fixes" },
{ message = "^bug", group = "Bug Fixes" },
{ message = "^doc", group = "Documentation" },
{ message = "^docs", group = "Documentation" },
{ message = "^perf", group = "Performance" },
{ message = "^app", group = "Application" },
{ message = "^api", group = "API" },
{ message = "^data", group = "Data" },
{ message = "^db", group = "Database" },
{ message = "^refactor", group = "Refactoring" },
{ message = "^style", group = "Styling" },
{ message = "^test", group = "Testing" },
{ message = "^setup", group = "Setup" },
{ message = "^infra", group = "Infrastructure" },
{ message = "^meta", group = "Meta" },
{ message = "^config", group = "Configuration" },
{ message = "^design", group = "Design" },
{ message = "^clean", group = "Cleanup" },
{ message = "^unit", group = "Testing" },
{ message = "^enhance", group = "Features" },
{ message = "^cicd", group = "DevOps" },
{ message = "^config", group = "Configuration" },
{ message = "^deploy", group = "Deployment" },
{ message = "^chore\\(release\\): prepare for", skip = true },
{ message = "^chore", group = "Miscellaneous Tasks", skip = true },
{ body = ".*security", group = "Security" },
]


# ------------------------------------------------------------------------------
# parse the commits based on https://www.conventionalcommits.org
# filter out the commits that are not conventional
# process each line of a commit as an individual commit
# regex for preprocessing the commit messages
# regex for parsing and grouping commits
# protect breaking changes from being skipped due to matching a skipping commit_parser
# filter out the commits that are not matched by commit parsers
# glob pattern for matching git tags
# regex for skipping tags
# regex for ignoring tags
# sort the tags chronologically
# sort the commits inside sections by oldest/newest order
# limit the number of commits included in the changelog
# ------------------------------------------------------------------------------
34 changes: 34 additions & 0 deletions .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Automate Changelog
on:
workflow_dispatch:
push:
branches:
- main
- develop
jobs:
changelog:
name: Generate changelog
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}

- name: Generate a changelog
uses: orhun/git-cliff-action@v1
id: git-cliff
with:
config: ./.github/cliff.toml
args: --verbose
env:
OUTPUT: ./CHANGELOG.md

- name: Print the changelog
run: cat "${{ steps.git-cliff.outputs.changelog }}"

- name: Commit and Push Changes
uses: actions-js/push@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
41 changes: 41 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Preview DNS Changes

on:
pull_request:
workflow_dispatch:

jobs:
dnscontrol:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Check
uses: koenrh/dnscontrol-action@v3
with:
args: check
config_file: 'dnscontrol.js'
creds_file: 'creds.json'

- name: Preview
id: dnscontrol_preview
uses: koenrh/dnscontrol-action@v3
with:
args: preview
config_file: 'dnscontrol.js'
creds_file: 'creds.json'

- name: Comment
uses: mshick/add-pr-comment@v1
with:
message: |
```
${{ steps.dnscontrol_preview.outputs.preview_comment }}
```
repo-token: ${{ secrets.GITHUB_TOKEN }}
allow-repeats: true
Empty file added CHANGELOG.md
Empty file.

0 comments on commit c9d102e

Please sign in to comment.