-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
86 lines (79 loc) · 3.27 KB
/
action.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
79
80
81
82
83
84
85
86
name: 'Build parameter yaml examples for Viash components'
author: Data Intuitive
description: >
This action will build nextflow parameter file templates
(see nextflow's -params-file option) for Viash workflows and components in a repository.
inputs:
target_dir:
required: false
description: 'The target directory. If not specified, the `target` path specified in the Viash project config (`_viash.yaml`) will be used. If that is not specified, the default `target/nextflow` will be used.'
viash_pro_token:
description: Viash Pro token.
required: true
tools_version:
description: >
Release of Viash tools to use.
required: false
default: 'latest'
runs:
using: 'composite'
steps:
- name: Get latest release
shell: bash
id: latestrelease
run: |
if [ "${{ inputs.tools_version }}" == "latest" ]; then
RELEASE_TAG=$(curl -s -L -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ inputs.token }}" -H "X-GitHub-Api-Version: 2022-11-28" https://api.github.com/repos/viash-io/viash_tools/releases/latest | jq -r '.tag_name')
else
RELEASE_TAG="${{ inputs.tools_version }}"
fi
echo "Using version $RELEASE_TAG"
echo "releasetag=$RELEASE_TAG" >> $GITHUB_OUTPUT
- uses: actions/checkout@v4
with:
repository: viash-io/viash_tools
token: ${{ inputs.viash_pro_token }}
path: viash_tools
ref: ${{ steps.latestrelease.outputs.releasetag }}
- name: Determine target directory
shell: bash
id: defaults
run: |
TARGET_DIR=${{ inputs.target_dir }}
if [ -z "$TARGET_DIR" ]; then
TARGET_DIR=$(yq -r '.target // "target/nextflow"' _viash.yaml)
fi
echo "target_dir=$TARGET_DIR" >> $GITHUB_OUTPUT
- name: 'Generate param files'
shell: bash
id: generate-params
run: |
command -v viash >/dev/null 2>&1 || { echo >&2 "Viash could not be found."; exit 127; }
TARGET_DIR="${{ steps.defaults.outputs.target_dir }}"
readarray -d '' BUILT_CONFIGS < <(find "$TARGET_DIR" -name .config.vsh.yaml -print0)
echo "Detected configs:"
printf "%s\n" "${BUILT_CONFIGS[@]}"
echo
NEXTFLOW_PARAMS=()
for config_path in "${BUILT_CONFIGS[@]}"; do
dir=$(dirname "$config_path")
NEXTFLOW_PARAMS+=("$dir/nextflow_params.yaml")
done
echo "Building Nextflow param files:"
printf "%s\n" "${NEXTFLOW_PARAMS[@]}"
echo
VIASH_VERSION=`viash -v | grep -oP 'viash \K[0-9.]+'`
IFS=. read -r major minor patch <<< $VIASH_VERSION
JOINED_CONFIGS=$(IFS=';'; printf '%s' "${BUILT_CONFIGS[*]}")
JOINED_PARAMS=$(IFS=';'; printf '%s' "${NEXTFLOW_PARAMS[*]}")
if (( "$major" > 0 )) || (( "$minor" >= 9 )); then
VIASH_VERSION_LONG=$(viash -v | grep -oP 'viash \K[0-9.]+.\w+')
viash_tools/target/docker/nextflow/generate_params_v9/generate_params_v9 \
--input "$JOINED_CONFIGS" \
--output "$JOINED_PARAMS" \
--viash_version $VIASH_VERSION_LONG
else
viash_tools/target/docker/nextflow/generate_params/generate_params \
--input "$JOINED_CONFIGS" \
--output "$JOINED_PARAMS"
fi