Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto upgrade pipeline #4835

Merged
merged 2 commits into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/workflows/update-dependencies.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Update python dependencies

on:
workflow_dispatch:
schedule:
- cron: "0 23 * * *"

jobs:
update-dependencies:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: "opensafely-core/setup-action@v1"
with:
python-version: "3.12"
install-just: true

- uses: actions/create-github-app-token@v1
id: generate-token
with:
app-id: 1031449 # opensafely-core Create PR app
private-key: ${{ secrets.CREATE_PR_APP_PRIVATE_KEY }}

- uses: bennettoxford/update-dependencies-action@v1
with:
token: ${{ steps.generate-token.outputs.token }}
# Note: just update pipeline library for now, as job-server uses dependabot for python upgrades
update_command: |
just upgrade-pipeline
4 changes: 3 additions & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ devenv: prodenv requirements-dev && install-precommit
$PIP install --no-deps -r requirements.dev.txt
touch $VIRTUAL_ENV/.dev


# ensure precommit is installed
install-precommit:
#!/usr/bin/env bash
Expand All @@ -110,6 +109,9 @@ upgrade env package="": virtualenv
test -z "{{ package }}" || opts="--upgrade-package {{ package }}"
FORCE=true {{ just_executable() }} requirements-{{ env }} $opts

# upgrade our internal pipeline library
upgrade-pipeline:
./scripts/upgrade-pipeline.sh requirements.prod.in

update-interactive-templates tag="": && prodenv
#!/usr/bin/env bash
Expand Down
16 changes: 16 additions & 0 deletions scripts/upgrade-pipeline.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash
set -eu

file=$1
github_package_url="opensafely-pipeline@https://github.com/opensafely-core/pipeline/archive/refs/tags/"
latest=$(git ls-remote -h --refs --tags --heads https://github.com/opensafely-core/pipeline | grep -o "v20.*$" | sort | tail -1)
echo "Latest version of pipeline is $latest"

# exit early if we are at the latest version
if grep -q "$latest" "$file"; then
echo "$file already contains latest version"
exit
fi

sed -i "s#$github_package_url.*\.zip#$github_package_url$latest.zip#" "$file"
echo "Updated $file to pipline $latest"