forked from nipoppy/nipoppy
-
Notifications
You must be signed in to change notification settings - Fork 0
78 lines (64 loc) · 2.88 KB
/
update_dataset_repos.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
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.")