|
| 1 | +name: Create Pull Request in Another Repository |
| 2 | +on: |
| 3 | + push: |
| 4 | + paths: 'releases' |
| 5 | + |
| 6 | +jobs: |
| 7 | + create-pull-request: |
| 8 | + runs-on: ubuntu-latest |
| 9 | + |
| 10 | + steps: |
| 11 | + - name: Check out the repository |
| 12 | + uses: actions/checkout@v3 |
| 13 | + - name: Set up Git and cloning repository |
| 14 | + env: |
| 15 | + TARGET_REPO: repronim/reproschema-py |
| 16 | + PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} |
| 17 | + run: | |
| 18 | + git config --global user.name "djarecka" |
| 19 | + git config --global user.email "djarecka@gmail.com" |
| 20 | + git clone https://x-access-token:${{ secrets.PERSONAL_ACCESS_TOKEN }}@github.com/$TARGET_REPO.git |
| 21 | + - name: Make changes to target repository |
| 22 | + id: changes |
| 23 | + run: | |
| 24 | + LAST_VERSION=$(ls -lt releases/ | grep ^d | head -1 | awk '{print $9}') |
| 25 | + echo "::set-output name=last_version::$LAST_VERSION" |
| 26 | + echo "Last Version" |
| 27 | + echo $LAST_VERSION |
| 28 | + cp releases/$LAST_VERSION/reproschema.jsonld reproschema-py/reproschema.jsonld |
| 29 | + cd reproschema-py |
| 30 | + git checkout -b new_release |
| 31 | + # TODO: change to pydantic model |
| 32 | + # TODO: a script to change CONTEXTFILE_URL can be added |
| 33 | + git add reproschema.jsonld |
| 34 | + git commit -m "Add new version of the model" |
| 35 | + cd .. |
| 36 | + - name: Push changes to target repository |
| 37 | + env: |
| 38 | + TARGET_REPO: repronim/reproschema-py |
| 39 | + PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} |
| 40 | + run: | |
| 41 | + cd reproschema-py |
| 42 | + git push origin new_release |
| 43 | + - name: Create pull request |
| 44 | + env: |
| 45 | + TARGET_REPO: repronim/reproschema-py |
| 46 | + PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} |
| 47 | + run: | |
| 48 | + curl -X POST -H "Authorization: token ${{ secrets.PERSONAL_ACCESS_TOKEN }}" \ |
| 49 | + -d '{"title":"Automated PR: Add new version of the model: ${{ steps.changes.outputs.last_version }}", "head":"new_release", "base":"main"}' \ |
| 50 | + https://api.github.com/repos/$TARGET_REPO/pulls |
0 commit comments