Skip to content

Commit 41cdc66

Browse files
authored
Merge pull request #12 from ElsLommelen/test-gha-fork
Test gha fork
2 parents 3b1615f + 9ed1ac0 commit 41cdc66

6 files changed

Lines changed: 140 additions & 3 deletions

File tree

‎.github/workflows/check_branch.yml‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Check the protocol on pull request
2+
3+
on:
4+
pull_request:
5+
types: [synchronize, opened, reopened, edited] #en zie https://github.com/actions/runner/issues/980
6+
branches:
7+
- main
8+
9+
jobs:
10+
build:
11+
if: startsWith(github.head_ref, 'sfp-')
12+
|| startsWith(github.head_ref, 'sip-')
13+
|| startsWith(github.head_ref, 'sop-')
14+
|| startsWith(github.head_ref, 'sap-')
15+
|| startsWith(github.head_ref, 'spp-')
16+
runs-on: ubuntu-latest
17+
name: "check protocol"
18+
env:
19+
GITHUB_PAT: ${{ secrets.PAT }}
20+
steps:
21+
- name: Check protocol
22+
uses: ElsLommelen/actions/protocol_check@protocols
23+
with:
24+
GITHUB_PAT: ${{ secrets.PAT }}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Check branch without protocol
2+
3+
on:
4+
pull_request:
5+
types: [synchronize, opened, reopened, edited]
6+
branches:
7+
- main
8+
9+
jobs:
10+
build:
11+
if: ${{!startsWith(github.head_ref, 'sfp-')
12+
&& !startsWith(github.head_ref, 'sip-')
13+
&& !startsWith(github.head_ref, 'sop-')
14+
&& !startsWith(github.head_ref, 'sap-')
15+
&& !startsWith(github.head_ref, 'spp-')}}
16+
runs-on: ubuntu-latest
17+
name: "check branch without protocol"
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v3
21+
with:
22+
fetch-depth: 0
23+
- name: Check where changes are made
24+
run: |
25+
git switch $GITHUB_HEAD_REF
26+
git checkout main
27+
git checkout $GITHUB_HEAD_REF
28+
if [ -n "$(git diff --name-only main | grep '^source/')" ]; then
29+
echo 'Branch '$GITHUB_HEAD_REF' contains changes in protocols. Please make a branch named after the protocol_code to add changes to a protocol. Protocol specific files:' $(git diff --name-only main | grep '^source/')
30+
exit 1
31+
fi
32+
if [ -n "$(git diff --name-only main | grep '^NEWS\.md$')" ]; then
33+
echo 'Branch '$GITHUB_HEAD_REF' contains changes in NEWS.md, while it is only allowed to change this file when adding a new protocol.'
34+
exit 1
35+
fi
36+
if [ -n "$(git diff --name-only main | grep '^\.zenodo\.json$')" ]; then
37+
echo 'Branch '$GITHUB_HEAD_REF' contains changes in NEWS.md, while it is only allowed to change this file when adding a new protocol.'
38+
exit 1
39+
fi

‎.github/workflows/release.yml‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
on:
2+
push:
3+
tags:
4+
- 'protocols-****.**'
5+
6+
name: Create Release
7+
8+
jobs:
9+
build:
10+
name: Create Release
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v2
15+
- name: Get tag message
16+
run: |
17+
TAG_BODY=$(git tag --contains ${{ github.sha }} -n100 | awk '(NR>1)')
18+
echo "::set-output name=TAG_BODY::$TAG_BODY"
19+
id: tag-body
20+
- name: Create Release
21+
id: create_release
22+
uses: actions/create-release@v1
23+
env:
24+
GITHUB_TOKEN: ${{ secrets.PAT }}
25+
with:
26+
tag_name: ${{ github.ref }}
27+
release_name: Release ${{ github.ref }}
28+
body: ${{ steps.tag-body.outputs.TAG_BODY }}
29+
draft: false
30+
prerelease: false
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: On merge to main, build the protocol and add it to the website
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
build-website:
10+
runs-on: ubuntu-latest
11+
name: "add protocol to website"
12+
env:
13+
GITHUB_PAT: ${{ secrets.PAT }}
14+
steps:
15+
- name: Checkout repo
16+
uses: ElsLommelen/actions/protocol_website@protocols
17+
with:
18+
GITHUB_PAT: ${{ secrets.PAT }}
19+
GITHUB_REPOSITORY_DEST: "ElsLommelen/protocols"
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Update protocol (.zenodo.json and NEWS.md)
2+
3+
on:
4+
pull_request_review:
5+
types: [submitted]
6+
branches:
7+
- main
8+
9+
jobs:
10+
build:
11+
if: (github.event.review.state == 'approved') &&
12+
(startsWith(github.head_ref, 'sfp-')
13+
|| startsWith(github.head_ref, 'sip-')
14+
|| startsWith(github.head_ref, 'sop-')
15+
|| startsWith(github.head_ref, 'sap-')
16+
|| startsWith(github.head_ref, 'spp-'))
17+
runs-on: ubuntu-latest
18+
name: "update protocol"
19+
env:
20+
GITHUB_PAT: ${{ secrets.PAT }}
21+
steps:
22+
- name: Update protocol
23+
uses: ElsLommelen/actions/protocol_update@protocols
24+
with:
25+
GITHUB_PAT: ${{ secrets.PAT }}

‎docker/entrypoint_check.sh‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ echo '\nSession info\n'
1010
Rscript -e 'sessioninfo::session_info()'
1111

1212
echo '\nCheck if only protocol is updated...\n'
13-
FOLDERNAME=$(Rscript -e 'protocolhelper::get_path_to_protocol("'$GITHUB_HEAD_REF'")')
14-
FOLDERNAME_REL=${FOLDERNAME#/home/runner/work/protocolsource/}
13+
FOLDERNAME=$(Rscript -e 'cat(protocolhelper::get_path_to_protocol("'$GITHUB_HEAD_REF'"))')
14+
FOLDERNAME_REL=${FOLDERNAME#/github/workspace/check/}
1515
echo 'FOLDERNAME=' $FOLDERNAME
1616
echo 'FOLDERNAME_REL=' $FOLDERNAME_REL
17-
CHANGED=$(git diff --name-only main | grep -v NEWS\.md | grep -v \.zenodo\.json| grep -v ^$FOLDERNAME_REL/)
17+
CHANGED=$(git diff --name-only main | grep -v NEWS\.md | grep -v \.zenodo\.json | grep -v \.Rprofile | grep -v ^$FOLDERNAME_REL/)
1818

1919
if [ -n "${CHANGED}" ]; then
2020
echo '\nBranch '$GITHUB_HEAD_REF' contains changes to files which do not belong to protocol '$GITHUB_HEAD_REF', and these changes will not be passed to the website. Please remove these changes from this branch and start a new branch for changes to other protocols. Changes to be removed:' $CHANGED

0 commit comments

Comments
 (0)