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

PR generator for new backend tags #5

Merged
merged 1 commit into from
Nov 28, 2023
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
33 changes: 33 additions & 0 deletions .generation/update_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/python3

'''
1. Set a new container tag
2. Increment the version number
'''

import argparse
import configparser
from pathlib import Path

CWD = Path('.generation/')
INI_FILE = CWD / 'config.ini'

parser = argparse.ArgumentParser(description='Update the config.ini file.')
parser.add_argument('--backendTag', dest='backend_tag', required=True, type=str, nargs=1,)

args = parser.parse_args()

config = configparser.ConfigParser()
config.read(INI_FILE)

config['input']['backendTag'] = args.backend_tag[0]

# retrieve version
version_digits: list[int] = [int(digit) for digit in config['package']['version'].split('.')]
# increment last version digit
version_digits[-1] += 1
# write back
config['package']['version'] = '.'.join(str(digit) for digit in version_digits)

with open(INI_FILE, 'w', encoding='utf-8') as f:
config.write(f)
34 changes: 34 additions & 0 deletions .github/workflows/create-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Update the generation and create a new PR

name: Generate and PR

on:
# schedule manually
workflow_dispatch:
inputs:
# On workflow dispatch, `branch` is selected by default
# You can access it in `github.ref_name`

backend_tag:
description: "Tag name for the container"
required: true
default: "pro-nightly-2023-11-14"

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Update config.ini
run: .generation/update_config.py --backendTag ${{ github.event.inputs.backend_tag }}

- name: Generate Code
run: .generation/generate.py

- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
with:
title: "Code for backend tag ${{ github.event.inputs.backend_tag }}"
commit-message: "Code for backend tag ${{ github.event.inputs.backend_tag }}"