Skip to content

Update Poetry lock on a regular basis #48

Update Poetry lock on a regular basis

Update Poetry lock on a regular basis #48

name: Update Poetry lock on a regular basis
on:
schedule:
- cron: '0 4 * * 0' # weekly at 04:00 on Sunday -> https://crontab.guru/#0_4_*_*_0
workflow_dispatch:
env:
# Versions are also listed in PR.yml
POETRY_VERSION: 1.2.2
PYTHON_VERSION: 3.9 # Use latest
jobs:
org-check:
name: Check GitHub Organization
if: github.repository_owner == 'ni'
runs-on: ubuntu-20.04
steps:
- name: Noop
run: "true"
update_poetry_lock:
name: Update Poetry Lock
runs-on: ubuntu-latest
needs: org-check
steps:
- uses: actions/checkout@v3
with:
ref: main # This is the branch the PR is to be created from
token: ${{ secrets.ADMIN_PAT }}
fetch-depth: 0
- name: Store vars
id: vars
run: |
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
echo "branch_name=automated-updates/update-poetry-lock" >> $GITHUB_OUTPUT
- name: Create branch
run: git checkout -b ${{ steps.vars.outputs.branch_name }}
- uses: actions/setup-python@v2
with:
python-version: ${{ env.PYTHON_VERSION }}
- uses: Gr1N/setup-poetry@v8
with:
poetry-version: ${{ env.POETRY_VERSION }}
- name: Configure git user
# https://github.com/actions/checkout/discussions/479
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Check for lock changes
run: |
poetry lock
poetry install
poetry run ni-python-styleguide fix
# based on https://stackoverflow.com/a/73340290/8100990
- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
with:
commit-message: Update poetry lock and reformat
title: Update Poetry Lock
branch: automated-updates/update-poetry-lock
branch-suffix: short-commit-hash
body: |
# Update Poetry Lock
Ran:
* `poetry lock`,
* `poetry install`, then
* `ni-python-styleguide fix` to reformat any changes.
\-\-\-
Created by Github action'
base: main
delete-branch: true
token: ${{ secrets.ADMIN_PAT }}