-
Notifications
You must be signed in to change notification settings - Fork 4
86 lines (74 loc) · 2.84 KB
/
new_x_from_issue.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: New Issue Processing
on:
issues:
types: [edited, labeled]
# opened
jobs:
process_template:
runs-on: ubuntu-latest
permissions:
actions: write
checks: write
contents: write
deployments: write
id-token: write
issues: write
# discussions: write
packages: write
pages: write
pull-requests: write
repository-projects: write
# security-events: write
statuses: write
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Read issue details
id: read_issue
run: |
repo_owner=${{ github.event.repository.owner.login }}
repo_name=${{ github.event.repository.name }}
repo_url="https://github.com/${repo_owner}/${repo_name}"
echo "::set-output name=title::${{ github.event.issue.title }}"
echo "::set-output name=submitter::${{ github.event.issue.user.login }}"
echo "::set-output name=url::$repo_url"
- name: Determine script to run
id: determine_script
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# title=$(echo "${{ steps.read_issue.outputs.title }}" | tr -d '[:punct:]' | tr '[:upper:]' '[:lower:]' | tr -d ' ')
# # this flattens the title and removed spaces, punctuation and case
# if [[ "$title" == *"addconsortium"* ]]; then
labels=$(gh issue view ${{ github.event.issue.number }} --json labels --jq '.labels[].name')
# {{github.event.issue.labels}}
for label in $labels; do
echo "$label"
if [[ "$label" == *"institution"* ]]; then
# echo "'$label' contains 'add_institution'"
echo "::set-output name=script::add/Institution.py"
break
elif [[ "$label" == *"consortium"* ]]; then
# echo "'$label' contains 'add_component'"
echo "::set-output name=script::add/Consortium.py"
break
fi
done
- name: Run Python script
id: run_python
env:
ISSUE_TITLE: ${{ steps.read_issue.outputs.title }}
ISSUE_BODY: |
${{ github.event.issue.body }}
# pipe should preseve newline properties for multilines
ISSUE_SUBMITTER: ${{ steps.read_issue.outputs.submitter }}
ISSUE_NUMBER: ${{ github.event.issue.number }}
REPO: ${{ steps.read_issue.outputs.url }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
script="${{ steps.determine_script.outputs.script }}"
if [ "$script" == "default" ]; then
echo "No specific script found for this issue."
else
python ".github/libs/$script"
fi