| 1 |
name: Add versions |
| 2 |
|
| 3 |
on: |
| 4 |
workflow_dispatch: {} |
| 5 |
schedule: |
| 6 |
# Every N hours |
| 7 |
- cron: '25 */4 * * *' |
| 8 |
|
| 9 |
permissions: |
| 10 |
contents: write |
| 11 |
pull-requests: write |
| 12 |
|
| 13 |
jobs: |
| 14 |
add_cpython: |
| 15 |
runs-on: ubuntu-slim |
| 16 |
steps: |
| 17 |
- uses: actions/checkout@v6 |
| 18 |
- uses: actions/setup-python@v6 |
| 19 |
with: |
| 20 |
python-version: 3 |
| 21 |
cache: 'pip' |
| 22 |
cache-dependency-path: plugins/python-build/scripts/requirements.txt |
| 23 |
- run: pip install -r plugins/python-build/scripts/requirements.txt |
| 24 |
|
| 25 |
- name: check for a release |
| 26 |
run: | |
| 27 |
python plugins/python-build/scripts/add_cpython.py --verbose >added_versions.lst && rc=$? || rc=$? |
| 28 |
#0 means new version found, 1 not found, 2 another error |
| 29 |
[[ $rc -gt 1 ]] && false |
| 30 |
echo "rc=$rc" >> $GITHUB_ENV |
| 31 |
- name: set PR properties |
| 32 |
if: env.rc == 0 |
| 33 |
shell: python |
| 34 |
run: | |
| 35 |
import os |
| 36 |
import sys |
| 37 |
versions=[l.rstrip() for l in open("added_versions.lst")] |
| 38 |
with open(os.environ['GITHUB_ENV'],'a') as f: |
| 39 |
f.write(f'branch_name=auto_add_version/{"_".join(versions)}\n') |
| 40 |
f.write(f'pr_name=Add CPython {", ".join(versions)}\n') |
| 41 |
os.remove("added_versions.lst") |
| 42 |
|
| 43 |
# https://github.com/peter-evans/create-pull-request/blob/main/docs/concepts-guidelines.md#authenticating-with-github-app-generated-tokens |
| 44 |
- name: Generate Github token |
| 45 |
if: env.rc == 0 |
| 46 |
uses: actions/create-github-app-token@v3 |
| 47 |
id: generate-token |
| 48 |
with: |
| 49 |
app-id: ${{ vars.PYENV_BOT_APP_ID }} |
| 50 |
private-key: ${{ secrets.PYENV_BOT_PRIVATE_KEY }} |
| 51 |
- name: Create Pull Request |
| 52 |
uses: peter-evans/create-pull-request@v8 |
| 53 |
if: env.rc == 0 |
| 54 |
with: |
| 55 |
branch: ${{ env.branch_name }} |
| 56 |
title: ${{ env.pr_name }} |
| 57 |
commit-message: ${{ env.pr_name }} |
| 58 |
token: ${{ steps.generate-token.outputs.token }} |