Skip to content

Git auto updater

Git auto updater #25

Workflow file for this run

name: update
on:
pull_request:
jobs:
update:
runs-on: ubuntu-latest
steps:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Check out repository
uses: actions/checkout@v4
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pru
- name: Determine current branch
id: current_branch
run: echo "CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)" >> $GITHUB_ENV
- name: Run requirements updater script
id: run_pru
run: |
bash .github/scripts/update_requirements.sh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Configure git
if: steps.run_pru.outputs.updated == 'true'
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
- name: Create new branch
if: steps.run_pru.outputs.updated == 'true'
run: |
BRANCH_NAME="update-requirements-${GITHUB_RUN_ID}"
git checkout -b $BRANCH_NAME
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
echo "DATE=${{ steps.run_pru.outputs.update_date }}" >> $GITHUB_ENV
- name: Commit changes
if: steps.run_pru.outputs.updated == 'true'
run: |
git add .
git commit -m "Update requirements based on failed tests at $DATE"
env:
DATE: ${{ steps.run_pru.outputs.update_date }}
- name: Push changes
if: steps.run_pru.outputs.updated == 'true'
run: |
git push origin $BRANCH_NAME
env:
BRANCH_NAME: ${{ env.BRANCH_NAME }}
- name: Create Pull Request
if: steps.run_pru.outputs.updated == 'true'
uses: peter-evans/create-pull-request@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: |
Update requirements based on failed tests
- Updated files: ${{ steps.run_pru.outputs.updated_files }}
- Date: ${{ steps.run_pru.outputs.update_date }}
branch: update-requirements-${{ github.run_id }}
title: 'Update requirements on ${{ steps.run_pru.outputs.update_date }}'
body: |
This PR updates the following requirements files based on the output of failed tests:
- ${{ steps.run_pru.outputs.updated_files }}
Date of update: ${{ steps.run_pru.outputs.update_date }}
labels: update, automated-pr