From 719e9521225899a5227abc1a7e7112469f10c26f Mon Sep 17 00:00:00 2001 From: selfkilla666 Date: Thu, 21 Dec 2023 15:57:38 +0200 Subject: [PATCH] Add action for autoupdate requirements.txt --- .github/workflows/update_requirements.yml | 47 +++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 .github/workflows/update_requirements.yml diff --git a/.github/workflows/update_requirements.yml b/.github/workflows/update_requirements.yml new file mode 100644 index 0000000..0b9bc0d --- /dev/null +++ b/.github/workflows/update_requirements.yml @@ -0,0 +1,47 @@ +name: Update requirements.txt + +on: + workflow_dispatch: + push: + paths: + - 'poetry.lock' + - 'pyproject.toml' + +jobs: + update-requirements: + name: Update requirements.txt + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: 3.11 + architecture: x64 + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install poetry + poetry install + + - name: Check for changes in poetry.lock + id: check_changes + run: | + git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep poetry.lock || echo "NO_CHANGES" + + - name: Update requirements.txt + if: steps.check_changes.outputs.NO_CHANGES != 'NO_CHANGES' + run: | + poetry export --dev --without-hashes -f requirements.txt > requirements.txt + + - name: Commit and push changes + if: steps.check_changes.outputs.NO_CHANGES != 'NO_CHANGES' + run: | + git config --global user.name "GitHub Actions" + git config --global user.email "actions@users.noreply.github.com" + git add requirements.txt + git commit -m "Autoupdate requirements.txt (CI)" + git push \ No newline at end of file