From ed703bc6d845078bf36e36ff970b7b52500e07e3 Mon Sep 17 00:00:00 2001 From: Dorota Jarecka Date: Wed, 19 Jun 2024 17:58:04 -0400 Subject: [PATCH 1/2] adding GA to create a PR to reproschema-py --- .github/workflows/push_reproschema_py.yml | 50 +++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 .github/workflows/push_reproschema_py.yml diff --git a/.github/workflows/push_reproschema_py.yml b/.github/workflows/push_reproschema_py.yml new file mode 100644 index 000000000..eb03ae0cc --- /dev/null +++ b/.github/workflows/push_reproschema_py.yml @@ -0,0 +1,50 @@ +name: Create Pull Request in Another Repository +on: + push: + paths: 'releases' + +jobs: + create-pull-request: + runs-on: ubuntu-latest + + steps: + - name: Check out the repository + uses: actions/checkout@v3 + - name: Set up Git and cloning repository + env: + TARGET_REPO: repronim/reproschema-py + PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} + run: | + git config --global user.name "djarecka" + git config --global user.email "djarecka@gmail.com" + git clone https://x-access-token:${{ secrets.PERSONAL_ACCESS_TOKEN }}@github.com/$TARGET_REPO.git + - name: Make changes to target repository + id: changes + run: | + LAST_VERSION=$(ls -lt releases/ | grep ^d | head -1 | awk '{print $9}') + echo "::set-output name=last_version::$LAST_VERSION" + echo "Last Version" + echo $LAST_VERSION + cp releases/$LAST_VERSION/reproschema.jsonld reproschema-py/reproschema.jsonld + cd reproschema-py + git checkout -b new_release + # TODO: change to pydantic model + # TODO: a script to change CONTEXTFILE_URL can be added + git add reproschema.jsonld + git commit -m "Add new version of the model" + cd .. + - name: Push changes to target repository + env: + TARGET_REPO: repronim/reproschema-py + PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} + run: | + cd reproschema-py + git push origin new_release + - name: Create pull request + env: + TARGET_REPO: repronim/reproschema-py + PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} + run: | + curl -X POST -H "Authorization: token ${{ secrets.PERSONAL_ACCESS_TOKEN }}" \ + -d '{"title":"Automated PR: Add new version of the model: ${{ steps.changes.outputs.last_version }}", "head":"new_release", "base":"main"}' \ + https://api.github.com/repos/$TARGET_REPO/pulls From 975624c439535dcd11a26ca195e64044e4360260 Mon Sep 17 00:00:00 2001 From: Dorota Jarecka Date: Thu, 20 Jun 2024 10:58:12 -0400 Subject: [PATCH 2/2] cheanging to workflow_dispatch with version as an input --- .github/workflows/push_reproschema_py.yml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/push_reproschema_py.yml b/.github/workflows/push_reproschema_py.yml index eb03ae0cc..6a9532af2 100644 --- a/.github/workflows/push_reproschema_py.yml +++ b/.github/workflows/push_reproschema_py.yml @@ -1,7 +1,11 @@ name: Create Pull Request in Another Repository on: - push: - paths: 'releases' + workflow_dispatch: + inputs: + version: + description: 'version number' + required: true + type: string jobs: create-pull-request: @@ -21,13 +25,9 @@ jobs: - name: Make changes to target repository id: changes run: | - LAST_VERSION=$(ls -lt releases/ | grep ^d | head -1 | awk '{print $9}') - echo "::set-output name=last_version::$LAST_VERSION" - echo "Last Version" - echo $LAST_VERSION - cp releases/$LAST_VERSION/reproschema.jsonld reproschema-py/reproschema.jsonld + cp releases/${{ inputs.version }}/reproschema.jsonld reproschema-py/reproschema.jsonld cd reproschema-py - git checkout -b new_release + git checkout -b release_${{ inputs.version }} # TODO: change to pydantic model # TODO: a script to change CONTEXTFILE_URL can be added git add reproschema.jsonld @@ -39,12 +39,12 @@ jobs: PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} run: | cd reproschema-py - git push origin new_release + git push origin release_${{ inputs.version }} - name: Create pull request env: TARGET_REPO: repronim/reproschema-py PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} run: | curl -X POST -H "Authorization: token ${{ secrets.PERSONAL_ACCESS_TOKEN }}" \ - -d '{"title":"Automated PR: Add new version of the model: ${{ steps.changes.outputs.last_version }}", "head":"new_release", "base":"main"}' \ + -d '{"title":"Automated PR: Add new version of the model: ${{ inputs.version }}", "head":"release_${{ inputs.version }}", "base":"main"}' \ https://api.github.com/repos/$TARGET_REPO/pulls