Skip to content

fix: ensure rubocop-compliant Brewfile #59

fix: ensure rubocop-compliant Brewfile

fix: ensure rubocop-compliant Brewfile #59

Workflow file for this run

---
name: Changelog
on:
push:
branches:
- main
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 4
if: ${{ !contains(github.event.head_commit.message, 'update changelog') }}
steps:
- uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.2.0
- name: Install `github_changelog_generator`
run: |
command gem install github_changelog_generator
- name: Install `markdownlint`
run: |
command npm install markdownlint
command npm install markdownlint-cli
- name: Build and commit changelog
run: |
file="$(
cd "$(
# attempt relative-path access
command git rev-parse \
--path-format=relative \
--show-toplevel
)" 2>/dev/null ||
cd "$(
command git rev-parse \
--show-toplevel
)" ||
exit "${?:-1}"
# find the Markdown changelog with the latest commit
command find -- "${PWD%/}" \
-path "${PWD%/}"'/[Cc][Hh][Aa][Nn][Gg][Ee]*[Ll][Oo][Gg]*' \
-path '.[Mm]*[Dd]*' \
-type f \
-exec sh -c '
command git log \
--max-count=1 \
--pretty=tformat:'\''%at '\''"${1-}"
' _ {} ';' |
LC_ALL='C' command sort -n -r |
command sed \
-n \
-e '1s/.*\///g' \
-e '1p' \
-e 'q'
)"
# define changelog location if none is found
file="${file:=changelog.md}"
# ensure the file exists
command touch -- "${file-}"
# create local changes
command github_changelog_generator \
--user "$(
command git ls-remote --get-url |
command sed \
-e '# replace colons with forward slashes' \
-e 's/:/\//g' \
-e '# remove everything except the second-to-last' \
-e '# forward slash-delimited field' \
-e 's/.*\/\([^/]*\)\/[^/]*/\1/'
)" \
--project "$(
command git ls-remote --get-url |
command sed \
-e 's/.*\///' \
-e 's/\.git$//'
)" \
--token ${{ secrets.GITHUB_TOKEN }} \
--exclude-labels 'duplicate,question,invalid,wontfix,nodoc' \
--output "${file-}"
# repair changelog credit
command sed \
-e 's/This Changelog/This changelog/' \
-e 's/automatically generated/\[automatically generated\]()/' \
-e 's/\]()/\](.\/.github\/workflows\/changelog.yml)/' \
-e 's/generator)\*/generator).\*/' \
./"${file-}" >./"${file%.*}"_temporary_"${file##*.}" &&
command mv -f -- ./"${file%.*}"_temporary_"${file##*.}" ./"${file-}"
# lint changelog
command npm exec -- markdownlint --fix -- ./"${file-}" ||
:
# commit files
command git config -- user.email 'actions@github.com'
command git config -- user.name 'GitHub'
command git restore --progress --staged -- .
command git add --verbose -- ./"${file-}"
command git commit --verbose --message='update changelog' ||
exit 0
- name: Push changes
uses: ad-m/github-push-action@v0.8.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}
...