bump awdeorio from a950978
to da76655
(#762)
#709
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
name: Changelog | |
on: | |
push: | |
branches: | |
- main | |
concurrency: | |
group: ${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
build: | |
runs-on: ubuntu-22.04 | |
timeout-minutes: 10 | |
if: "!contains(github.event.head_commit.message, 'update changelog')" | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Ruby | |
uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: 3.1.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="$( | |
( | |
command find -- . \ | |
-maxdepth 1 \ | |
-type f \ | |
-name '*.m*d*' \ | |
'(' \ | |
-name 'change*log*' -o \ | |
-name 'CHANGE*LOG*' \ | |
')' \ | |
-print & | |
) | | |
# print only the first match | |
command head -n 1 | |
)" | |
# define changelog location if none is found | |
file="${file:=./changelog.md}" | |
# ensure the file exists | |
command touch -- "${file-}" | |
# trim the initial `./` for `github_changelog_generator` | |
file="${file#*[.][/]}" | |
# create local changes | |
command github_changelog_generator \ | |
--user "$( | |
command git ls-remote --get-url | | |
command sed \ | |
-e '# replace colons with forward slashes' \ | |
-e 'y/:/\//' \ | |
-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 || secrets.PAT }} \ | |
--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 add --verbose -- ./"${file-}" | |
command git commit --verbose --message='update changelog' || | |
exit 0 | |
- name: Push changes | |
uses: ad-m/github-push-action@v0.6.0 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN || secrets.PAT }} | |
branch: ${{ github.ref }} | |
... |