Skip to content

Update to match neurodatascience/nipoppy:main (#108) #50

Update to match neurodatascience/nipoppy:main (#108)

Update to match neurodatascience/nipoppy:main (#108) #50

name: Update dataset repos
on:
push:
branches:
- 'main'
jobs:
update-dataset-repo:
if: github.repository == 'neurodatascience/nipoppy'
runs-on: ubuntu-latest
env:
TEMPLATE_REPO: neurodatascience/nipoppy
strategy:
fail-fast: false
matrix:
fork:
- neurodatascience/nipoppy-nimhans_retro
- neurodatascience/nipoppy-nimhans_YLO
- neurodatascience/nipoppy-ppmi
- neurodatascience/nipoppy-qpn
steps:
- uses: actions/checkout@v3
with:
repository: ${{ matrix.fork }}
- name: Get upstream changes
run: |
git remote add upstream https://github.com/${TEMPLATE_REPO}.git
git fetch upstream main
git reset --hard upstream/main
- name: Create Pull Request
id: create-pull-request
uses: peter-evans/create-pull-request@v4
with:
title: Update to match ${{ env.TEMPLATE_REPO }}:main
body: PR created/updated automatically by [create-pull-request](https://github.com/peter-evans/create-pull-request) GitHub action. Will be merged automatically by [automerge-action](https://github.com/pascalgn/automerge-action) if there are no merge conflicts.
token: ${{ secrets.PAT }}
branch: main-upstream
labels: automerge
- name: Approve Pull Request
if: ${{ steps.create-pull-request.outputs.pull-request-number }}
uses: michellewang/auto-approve-action@v3
with:
repository: ${{ matrix.fork }}
pull-request-number: ${{ steps.create-pull-request.outputs.pull-request-number }}
review-message: PR approved by [auto-approve-action](https://github.com/michellewang/auto-approve-action) GitHub action.
github-token: ${{ secrets.GH_ACTION_PAT }}
- name: Automerge Pull Request
id: automerge-pull-request
if: ${{ steps.create-pull-request.outputs.pull-request-number }}
uses: pascalgn/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.PAT }}
MERGE_LABELS: automerge
MERGE_METHOD: merge
MERGE_COMMIT_MESSAGE: "{pullRequest.title} (#{pullRequest.number})"
MERGE_REQUIRED_APPROVALS: 1
MERGE_DELETE_BRANCH: "false"
MERGE_ERROR_FAIL: "true"
PULL_REQUEST: ${{ matrix.fork }}/${{ steps.create-pull-request.outputs.pull-request-number }}
- name: Fail job if Pull Request wasn't ready to be merged
if: steps.automerge-pull-request.outputs.mergeResult == 'not_ready'
uses: actions/github-script@v6
with:
script: |
core.setFailed("Pull request #${{ steps.automerge-pull-request.outputs.pullRequestNumber }} is not ready to be merged. This is probably due to merge conflicts: fix them in ${{ env.TEMPLATE_REPO }} or in each of ${{ env.TEMPLATE_REPO }}-[dataset] before trying again.")