mirror of
https://github.com/super-linter/super-linter.git
synced 2024-11-29 09:30:58 -05:00
Add workflow for Python updates
This commit is contained in:
parent
12927d1882
commit
4a938c367e
2 changed files with 91 additions and 0 deletions
76
.github/scripts/update-python.sh
vendored
Executable file
76
.github/scripts/update-python.sh
vendored
Executable file
|
@ -0,0 +1,76 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
################################################################################
|
||||||
|
########################### Install Python Dependancies ########################
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
#####################
|
||||||
|
# Set fail on error #
|
||||||
|
#####################
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
############################
|
||||||
|
# Create staging directory #
|
||||||
|
############################
|
||||||
|
mkdir -p /venvs
|
||||||
|
|
||||||
|
########################################
|
||||||
|
# Install basic libs to run installers #
|
||||||
|
########################################
|
||||||
|
pip install virtualenv
|
||||||
|
|
||||||
|
#########################################################
|
||||||
|
# Itterate through requirments.txt to install bainaries #
|
||||||
|
#########################################################
|
||||||
|
cd dependencies/python
|
||||||
|
for DEP_FILE in *.txt; do
|
||||||
|
# split the package name from its version
|
||||||
|
PACKAGE_NAME=${DEP_FILE%.txt}
|
||||||
|
echo "-------------------------------------------"
|
||||||
|
mkdir -p "/venvs/${PACKAGE_NAME}"
|
||||||
|
echo "Generating virtualenv for: [${PACKAGE_NAME}]"
|
||||||
|
pushd "/venvs/${PACKAGE_NAME}"
|
||||||
|
# Enable virtualenv
|
||||||
|
virtualenv .
|
||||||
|
# Activate virtualenv
|
||||||
|
source bin/activate
|
||||||
|
# Handle the ansibl-lint corner case
|
||||||
|
if [[ "$PACKAGE_NAME" == "ansible-lint" ]]; then
|
||||||
|
pip install "ansible-lint[core]"
|
||||||
|
else
|
||||||
|
pip install "${PACKAGE_NAME}"
|
||||||
|
fi
|
||||||
|
# Generate an update requirements.txt
|
||||||
|
pip freeze > requirements.txt
|
||||||
|
# deactivate the python virtualenv
|
||||||
|
deactivate
|
||||||
|
# pop the stack
|
||||||
|
popd
|
||||||
|
# Remove old lockfile
|
||||||
|
rm -rf "$DEP_FILE"
|
||||||
|
# Create new lockfile
|
||||||
|
mv "/venvs/${PACKAGE_NAME}/requirements.txt" "${DEP_FILE}"
|
||||||
|
done
|
||||||
|
|
||||||
|
git status
|
||||||
|
|
||||||
|
# Setup Git Config
|
||||||
|
echo "Configuring Git..."
|
||||||
|
git config --global user.email "noreply@github.com"
|
||||||
|
git config --global user.name "Super-Linter Automation"
|
||||||
|
|
||||||
|
if [[ $(git status --porcelain) ]]; then
|
||||||
|
# Push changes to remote
|
||||||
|
echo "Pushing changes to remote..."
|
||||||
|
git add .
|
||||||
|
git commit -a -Ss -m "Update Python dependencies"
|
||||||
|
# shellcheck disable=SC2154
|
||||||
|
git checkout -b "python_deps_${id}"
|
||||||
|
# shellcheck disable=SC2154
|
||||||
|
git push origin "python_deps_${id}"
|
||||||
|
|
||||||
|
# Open pull request
|
||||||
|
echo "Opening pull request..."
|
||||||
|
gh pr create --title "Weekly Python Updates" --body "Updates Python dependencies" --base master --head "python_deps_${id}"
|
||||||
|
else
|
||||||
|
echo "No changes to commit"
|
||||||
|
fi
|
15
.github/workflows/deps-python.yml
vendored
Normal file
15
.github/workflows/deps-python.yml
vendored
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
name: Update Deps - Python
|
||||||
|
on:
|
||||||
|
schedule:
|
||||||
|
# Sunday at 5:00pm
|
||||||
|
- cron: "0 17 * * 0"
|
||||||
|
workflow_dispatch:
|
||||||
|
jobs:
|
||||||
|
update:
|
||||||
|
name: Update Python Dependencies
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- run: ./.github/scripts/update-python.sh
|
||||||
|
env:
|
||||||
|
id: ${{ github.run_id }}
|
Loading…
Reference in a new issue