Add update-dependencies workflow
This commit is contained in:
parent
22f424dcb0
commit
cf5015e0d7
4 changed files with 59 additions and 2 deletions
1
.github/workflows/publish.yaml
vendored
1
.github/workflows/publish.yaml
vendored
|
@ -1,6 +1,7 @@
|
||||||
name: Build, publish & deploy
|
name: Build, publish & deploy
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
|
|
1
.github/workflows/test.yaml
vendored
1
.github/workflows/test.yaml
vendored
|
@ -1,6 +1,7 @@
|
||||||
name: Test
|
name: Test
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
workflow_call:
|
workflow_call:
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [ "master" ]
|
branches: [ "master" ]
|
||||||
|
|
39
.github/workflows/update-dependencies.yaml
vendored
Normal file
39
.github/workflows/update-dependencies.yaml
vendored
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
name: Update dependencies
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
schedule:
|
||||||
|
- cron: '0 18 * * TUE'
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
pull-requests: write
|
||||||
|
contents: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
update:
|
||||||
|
name: Update dependencies
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
ref: master
|
||||||
|
- name: Set up Python
|
||||||
|
uses: actions/setup-python@v4
|
||||||
|
with:
|
||||||
|
python-version: '3.11'
|
||||||
|
cache: pip
|
||||||
|
- name: Update dependencies
|
||||||
|
run: |
|
||||||
|
pip install pip-tools invoke
|
||||||
|
invoke update-dependencies --no-sync
|
||||||
|
- name: Create Pull Request
|
||||||
|
uses: peter-evans/create-pull-request@v4
|
||||||
|
id: create-pull-request
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.PERSONAL_TOKEN_PR }}
|
||||||
|
commit-message: Update dependencies
|
||||||
|
base: master
|
||||||
|
branch: update-dependencies
|
||||||
|
title: Update dependencies
|
||||||
|
delete-branch: true
|
20
tasks.py
20
tasks.py
|
@ -20,8 +20,17 @@ COMPOSE_BUILD_ENV = {"COMPOSE_FILE": COMPOSE_BUILD_FILE}
|
||||||
|
|
||||||
|
|
||||||
@task
|
@task
|
||||||
def update_dependencies(ctx: Context) -> None:
|
def update_dependencies(ctx: Context, *, sync: bool = True) -> None:
|
||||||
common_args = "-q --allow-unsafe --resolver=backtracking --upgrade"
|
return compile_dependencies(ctx, update=True, sync=sync)
|
||||||
|
|
||||||
|
|
||||||
|
@task
|
||||||
|
def compile_dependencies(
|
||||||
|
ctx: Context, *, update: bool = False, sync: bool = False
|
||||||
|
) -> None:
|
||||||
|
common_args = "-q --allow-unsafe --resolver=backtracking"
|
||||||
|
if update:
|
||||||
|
common_args += " --upgrade"
|
||||||
with ctx.cd(BASE_DIR):
|
with ctx.cd(BASE_DIR):
|
||||||
ctx.run(
|
ctx.run(
|
||||||
f"pip-compile {common_args} --generate-hashes requirements.in",
|
f"pip-compile {common_args} --generate-hashes requirements.in",
|
||||||
|
@ -38,6 +47,13 @@ def update_dependencies(ctx: Context) -> None:
|
||||||
pty=True,
|
pty=True,
|
||||||
echo=True,
|
echo=True,
|
||||||
)
|
)
|
||||||
|
if sync:
|
||||||
|
sync_dependencies(ctx)
|
||||||
|
|
||||||
|
|
||||||
|
@task
|
||||||
|
def sync_dependencies(ctx: Context) -> None:
|
||||||
|
with ctx.cd(BASE_DIR):
|
||||||
ctx.run("pip-sync requirements.txt requirements-dev.txt", pty=True, echo=True)
|
ctx.run("pip-sync requirements.txt requirements-dev.txt", pty=True, echo=True)
|
||||||
|
|
||||||
|
|
||||||
|
|
Reference in a new issue