Automatic patch release #847
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: Automatic patch release | |
on: | |
schedule: | |
- cron: '0 0 * * *' | |
workflow_dispatch: | |
jobs: | |
auto-patch: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: '0' | |
- id: count-commits | |
name: Count commits | |
run: | | |
last_release=`git describe --abbrev=0 --tags` | |
total_new_commits=`git log $last_release..main --pretty=oneline | wc -l` | |
echo "Commits by everyone: $total_new_commits" | |
echo "::set-output name=by-everyone::$total_new_commits" | |
commits_by_dependabot=`git log $last_release..main --author="dependabot" --author="GitHub Actions" --pretty=oneline | wc -l` | |
echo "Commits by dependabot: $commits_by_dependabot" | |
echo "::set-output name=by-dependabot::$commits_by_dependabot" | |
- uses: oleksiyrudenko/gha-git-credentials@v2-latest | |
with: | |
token: '${{ secrets.GITHUB_TOKEN }}' | |
name: 'GitHub Actions' | |
email: 'bots@example.com' | |
- name: Make a patch release if all commits since last release were by dependabot | |
if: ${{ steps.count-commits.outputs.by-everyone == steps.count-commits.outputs.by-dependabot }} | |
run: | | |
yarn version --patch | |
- uses: ad-m/github-push-action@master | |
if: ${{ steps.count-commits.outputs.by-everyone == steps.count-commits.outputs.by-dependabot }} | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
branch: main | |
tags: true |