-
Notifications
You must be signed in to change notification settings - Fork 14
60 lines (51 loc) · 2.29 KB
/
Copy pathtemplate-version-comment.yml
File metadata and controls
60 lines (51 loc) · 2.29 KB
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
name: nf-core template version comment
# This workflow is triggered on PRs to check if the pipeline template version matches the latest nf-core version.
# It posts a comment to the PR, even if it comes from a fork.
on:
pull_request:
permissions: {}
jobs:
check_template_version:
runs-on: ubuntu-latest
steps:
- name: Check out pipeline code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Read template version from .nf-core.yml
uses: nichmor/minimal-read-yaml@1f7205277e25e156e1f63815781db80a6d490b8f # v0.0.2
id: read_yml
with:
config: ${{ github.workspace }}/.nf-core.yml
- name: Install nf-core
run: |
python -m pip install --upgrade pip
pip install nf-core
- name: Build PR comment if template is outdated
# The fork-controlled version is passed via the environment and only ever
# used as quoted shell data (never interpolated into a command), so it
# cannot be used for script injection.
env:
PR_VERSION: ${{ steps.read_yml.outputs['nf_core_version'] }}
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
mkdir -p pr-comment
echo "$PR_NUMBER" > pr-comment/pr_number.txt
echo "template-version" > pr-comment/header.txt
latest_version=$(nf-core --version | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -n1)
if [ -n "$PR_VERSION" ] && [ -n "$latest_version" ] && [ "$PR_VERSION" != "$latest_version" ]; then
cat > pr-comment/comment.md <<EOF
> [!WARNING]
> Newer version of the nf-core template is available.
>
> Your pipeline is using an old version of the nf-core template: ${PR_VERSION}.
> Please update your pipeline to the latest version.
>
> For more documentation on how to update your pipeline, please see the [Synchronisation documentation](https://nf-co.re/docs/developing/template-syncs/overview).
EOF
fi
- name: Upload PR comment artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: pr-comment
path: pr-comment/