From da799adfa083932b973f959ce5b6cbaa74e9537f Mon Sep 17 00:00:00 2001 From: Lumir Balhar Date: Thu, 16 May 2024 22:49:43 +0200 Subject: [PATCH] Workflow for automatic update of supported pip --- .github/workflows/update_pip.yml | 23 +++++++++++++++++++ .github/workflows/update_supported_pip.sh | 28 +++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 .github/workflows/update_pip.yml create mode 100755 .github/workflows/update_supported_pip.sh diff --git a/.github/workflows/update_pip.yml b/.github/workflows/update_pip.yml new file mode 100644 index 0000000..1087e9b --- /dev/null +++ b/.github/workflows/update_pip.yml @@ -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 diff --git a/.github/workflows/update_supported_pip.sh b/.github/workflows/update_supported_pip.sh new file mode 100755 index 0000000..1634775 --- /dev/null +++ b/.github/workflows/update_supported_pip.sh @@ -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