main #387
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: main | |
on: | |
push: | |
branches: [main] | |
schedule: | |
- cron: '15 8 * * *' | |
jobs: | |
build: | |
name: main | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v4 | |
- run: pip install pre-commit-mirror-maker | |
- run: git config --global user.name 'Github Actions' | |
- run: git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com' | |
- run: > | |
pre-commit-mirror . | |
--id=commitlint | |
--package-name=commitlint | |
--description "runs commitlint on the message of the commit being made" | |
--entry='commitlint --edit' | |
--language=node | |
--types=text | |
# pre-commit-mirror-maker has no support for multiple/additional hooks. Add | |
# additional hooks manually. | |
- run: | | |
# If no version was released, then there is nothing to change | |
if [[ ! "$(git status -sb)" =~ "ahead" ]]; then exit 0; fi | |
latest_tag="$(git describe --tags --abbrev=0)" | |
# Add additional hooks | |
cat <<END >> .pre-commit-hooks.yaml | |
- id: commitlint-all | |
name: commitlint-all | |
description: 'runs commitlint in CI on all commit messages' | |
entry: commitlint --from -- | |
language: node | |
'types': [text] | |
args: [] | |
require_serial: false | |
additional_dependencies: ["commitlint@${latest_tag:1}"] | |
minimum_pre_commit_version: '0' | |
END | |
# Amend both the commit and tag with the additions | |
git commit --amend -a --no-edit | |
git tag -f $latest_tag | |
- run: | | |
git remote set-url origin https://x-access-token:$GH_TOKEN@github.com/$GITHUB_REPOSITORY | |
git push origin HEAD:refs/heads/main --tags | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |