-
-
Notifications
You must be signed in to change notification settings - Fork 11
152 lines (134 loc) · 4.88 KB
/
uninew.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
name: New University
on:
issues:
types: [opened, edited]
permissions:
pull-requests: write
contents: write
jobs:
autopr:
if: ${{ startsWith(github.event.issue.title, '[New University]') }}
runs-on: ubuntu-latest
env:
USER_LOGIN: ${{ github.event.issue.user.login }}
USER_NAME: ${{ github.event.issue.user.name }}
USER_ID: ${{ github.event.issue.user.id }}
ISSUE_ID: ${{ github.event.issue.id }}
ISSUE_NUMBER: ${{ github.event.issue.number }}
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.AUTOPR_PAT }}
- uses: stefanbuck/github-issue-parser@v3
id: issue
with:
template-path: .github/ISSUE_TEMPLATE/uninew.yml
- name: Find country information
uses: sanjacob/country-iso@v2
id: country
env:
COUNTRY: ${{ steps.issue.outputs.issueparser_country }}
with:
name: ${{ env.COUNTRY }}
- name: Set issue environment variables
env:
NAME: ${{ steps.issue.outputs.issueparser_name }}
START_URL: ${{ steps.issue.outputs.issueparser_login-start-url }}
TARGET_URL: ${{ steps.issue.outputs.issueparser_login-target-url }}
run: |
echo "UNI_NAME=$NAME" >> $GITHUB_ENV
echo "UNI_START_URL=${START_URL%'/'}" >> $GITHUB_ENV
echo "UNI_TARGET_URL=${TARGET_URL%'/'}/" >> $GITHUB_ENV
- name: Insert university into database
uses: sanjacob/json-insert@v1.1
env:
UNI_SHORT_NAME: ${{ steps.issue.outputs.issueparser_short-name }}
with:
file: blackboard_sync/universities.json
index: -2
item: |
{
"name": "${{ env.UNI_NAME }}",
"short_name": "${{ env.UNI_SHORT_NAME }}",
"country": "${{ steps.country.outputs.iso-2 }}",
"login": {
"start_url": "${{ env.UNI_START_URL }}",
"target_url": "${{ env.UNI_TARGET_URL }}"
},
"api_url": "${{ env.UNI_START_URL }}"
}
- name: Map country code to country section
uses: kanga333/variable-mapper@c140b458cb69bd8c9c5eccd41e83aadc597c1352
id: header
with:
key: "${{ steps.country.outputs.iso-2 }}"
map: |
{
"MX": { "section": "Mexico" },
"NZ": { "section": "New Zealand" },
"CA": { "section": "Canada" },
"US": { "section": "United States of America" },
"GB": { "section": "England" },
".*": { "section": "" }
}
export_to: output
- name: Map country code to continent section
if: ${{ steps.header.outputs.section == '' }}
uses: kanga333/variable-mapper@c140b458cb69bd8c9c5eccd41e83aadc597c1352
id: header-b
with:
key: "${{ steps.country.outputs.continent }}"
map: |
{
"AF": { "section": "Africa" },
"AS": { "section": "Asia" },
"EU": { "section": "Rest of Europe" },
"NA": { "section": "United States of America" },
"OC": { "section": "Australia" },
"SA": { "section": "South America" },
".*": { "section": "Not Found" }
}
export_to: output
- name: Append university to UNIVERSITIES
uses: sanjacob/markdown-list@v1
env:
HEADER_A: ${{ steps.header.outputs.section }}
HEADER_B: ${{ steps.header-b.outputs.section }}
with:
file: "UNIVERSITIES.md"
header: ${{ env.HEADER_A || env.HEADER_B }}
item: ${{ env.UNI_NAME }}
- name: Add entry to CHANGELOG
uses: sanjacob/markdown-list@v1
with:
file: "CHANGELOG.md"
header: Added
item: >
Add support for ${{ env.UNI_NAME }} (@${{ env.USER_LOGIN }})
- name: Create new branch
run: |
git switch -c "uni-$ISSUE_ID"
- name: Set GitHub commit author
env:
COMMIT_AUTHOR: ${{ env.USER_NAME || env.USER_LOGIN }}
run: |
USER_EMAIL="${USER_ID}+${USER_LOGIN}@users.noreply.github.com"
git config user.name $COMMIT_AUTHOR
git config user.email $USER_EMAIL
- name: Create commit
run: |
git add .
git commit -m "Add support for $UNI_NAME"
- name: Push new branch to origin
run: git push origin "uni-$ISSUE_ID" --force
- name: Set GitHub PR author
run: |
git config user.name github-actions
git config user.email github-actions@github.com
- name: Create pull request
run: >
gh pr create -B main -H "uni-$ISSUE_ID" --fill
--body "Created on behalf of @$USER_LOGIN
Closes #$ISSUE_NUMBER" || true
env:
GITHUB_TOKEN: ${{ secrets.AUTOPR_PAT }}