Autoupdate #237
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: Autoupdate | |
on: | |
push: | |
workflow_dispatch: | |
schedule: | |
- cron: "0 0 1 * *" # Run every month | |
jobs: | |
main: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out repository code | |
uses: actions/checkout@v3 | |
- name: Set up Python 3.12 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.12 | |
- name: Install dependencies | |
run: python3 -m pip install --upgrade pip copier poetry poetry-plugin-up | |
- name: Update template | |
run: make all | |
- name: Check if we should commit | |
id: commit_check | |
run: | | |
if git diff --quiet | |
then | |
echo "should_commit==false" >> $GITHUB_OUTPUT | |
else | |
echo "should_commit==true" >> $GITHUB_OUTPUT | |
fi | |
- name: Commit updated lockfiles | |
uses: EndBug/add-and-commit@v9 | |
id: make_commit | |
if: ${{ contains(steps.commit_check.outputs.should_commit, 'true') }} | |
with: | |
default_author: github_actions | |
message: ":robot: :arrow_up: Updated deps and lockfile\n\nThis is an automated action" | |
- name: Generate tag | |
id: gen_tag_name | |
if: ${{ contains(steps.commit_check.outputs.should_commit, 'true') }} | |
run: | | |
git fetch --tags | |
NEW_TAG=$(git tag -l | sort -V | tail -n 1 | awk -F. -v OFS=. 'NF==1{print ++$NF}; NF>1{$NF=sprintf("%0*d", length($NF), ($NF+1)); print}') | |
echo "NEW_TAG=$NEW_TAG" >> "$GITHUB_OUTPUT" | |
- uses: rickstaa/action-create-tag@v1 | |
if: ${{ contains(steps.commit_check.outputs.should_commit, 'true') }} | |
with: | |
tag: "${{ steps.gen_tag_name.outputs.NEW_TAG }}" | |
commit_sha: "${{ steps.make_commit.outputs.commit_long_sha }}" |