Skip to content

Commit

Permalink
Workflow for automatic update of supported pip
Browse files Browse the repository at this point in the history
  • Loading branch information
frenzymadness committed May 17, 2024
1 parent bfb04b2 commit da799ad
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/update_pip.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Check and update supported pip

on:
schedule:
- cron: '0 0 * * *' # Runs daily at midnight
workflow_dispatch: # Allows manual triggering

jobs:
check-pip-update:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2

- name: Run the update script
run: |
.github/workflows/update_supported_pip.sh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # GitHub token for authentication
28 changes: 28 additions & 0 deletions .github/workflows/update_supported_pip.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

# Get the latest pip release
python3 -m venv venv
./venv/bin/pip install --upgrade pip
PIP_VERSION=$(./venv/bin/pip --version | awk '{print $2}')

# Replace it in the micropipenv.py
sed -i "/_SUPPORTED_PIP_STR/s/<=[^\"]*\"/<=$PIP_VERSION\"/" micropipenv.py

# Is there any change to propose?
if [[ -n $(git status --porcelain --untracked-files=no) ]]; then
echo "New pip available"

# Commit the change
git config --global user.email "lbalhar@redhat.com"
git config --global user.name "Lumír Balhar"
git checkout -b update-pip-$PIP_VERSION
git add micropipenv.py
git commit -m "Update supported pip to $PIP_VERSION"
GIT_SSH_COMMAND='ssh -o StrictHostKeyChecking=no' git push origin update-pip-$PIP_VERSION

# Create a pull request using GitHub CLI
gh pr create --title "Update supported pip to $PIP_VERSION" --body "SSIA"

else
echo "There is nothing to be done…"
fi

0 comments on commit da799ad

Please sign in to comment.