This repository has been archived by the owner on Mar 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 65
152 lines (140 loc) · 6.9 KB
/
on-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
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
name: Create a New Event PR
on:
issues:
types:
- "opened"
jobs:
createNewEventPr:
if: contains(github.event.issue.labels.*.name, 'new-event')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
clean: true
fetch-depth: 0
- name: Get Information to file
run: |
Write-Host "What do we have?"
$Event = @"
${{ toJson(github.event) }}
"@
Write-Host $Event
$IssueBody = @"
${{ github.event.issue.body }}
"@
# Write-Host $IssueBody
$IssueBody | Out-File ./temp/temp.txt
shell: pwsh
continue-on-error: true
- name: Add & Commit
uses: EndBug/add-and-commit@v8.0.2
with:
author_name: Beardy McBeardFace
author_email: mrrobsewell@outlook.com
message: 'Added the temp file to the repo for issue number #${{ github.event.issue.number }} raised by @${{ github.event.issue.user.login }} ***NO_CI***'
new_branch: 'new-event-issue-${{ github.event.issue.number }}'
push: origin new-event-issue-${{ github.event.issue.number }} --set-upstream --force
continue-on-error: true
- name: Parse the temp file and create the other files
run: |
# get the temp file contents - I do this so I dont lose anything
$file = Get-Content ./temp/temp.txt -Raw
# parse the issue
$regexResult = [regex]::Matches($file, '(?ms)eventname\n\n(?<eventname>.*)\n\n### date\n\n(?<date>.*)\n\n### description\n\n(?<description>.*)\n\n### registrationurl\n\n(?<registrationurl>.*)\n\n### rooms\n\n(?<rooms>.*)\n\n### scheduleurl\n\n(?<scheduleurl>.*)\n\n### sponsors\n\n(?<sponsors>.*)\n\n### speakerlisturl\n\n(?<speakerlisturl>.*)\n\n### volunteerrequesturl\n\n(?<volunteerrequesturl>.*)\n\n### organizers\n\n(?<organizers>.*)\n')
# create an object
$eventObject = [PSCustomObject]@{
eventname = $regexResult[0].Groups['eventname'].Value
date = $regexResult[0].Groups['date'].Value
description = $regexResult[0].Groups['description'].Value
registrationurl = $regexResult[0].Groups['registrationurl'].Value
rooms = $regexResult[0].Groups['rooms'].Value
scheduleurl = $regexResult[0].Groups['scheduleurl'].Value
sponsors = $regexResult[0].Groups['sponsors'].Value
speakerlisturl = $regexResult[0].Groups['speakerlisturl'].Value
volunteerrequesturl = $regexResult[0].Groups['volunteerrequesturl'].Value
organizers = $regexResult[0].Groups['organizers'].Value
}
#save it to a file
$eventname = $eventObject.eventname -replace ' ', '-' -replace '''','-' -replace '/','-' -replace '\\','-' -replace ':','-' -replace '\*','-' -replace '\?','-' -replace '"','-' -replace '\|','-'
$date = Get-Date -Format "yyyy-MM-dd_HHmmss"
$eventDate = [datetime]$eventObject.date
$filePath = './temp/{0}_{1}.json' -f $eventname, $date
$eventObject |ConvertTo-Json | Out-FIle -FilePath $filePath
## Create the files as required
[int]$latest = ((Get-ChildItem ./_data/events).Name | Sort-Object -Descending | Select-Object -First 1 ) -replace '.yml','' -replace 'datasaturday',''
$newNumber = '{0:d4}' -f ($latest + 1)
$yamlFileName = './_data/events/datasaturday{0}.yml' -f $newNumber
$mdFileName = './_posts/{0}-datasaturday{1}.md' -f $eventDate.ToString("yyyy-MM-dd"), $newNumber
$mdcontent = @"
---
layout: post
title: "Data Saturday #{0} {1}"
subtitle: "Data Saturday"
tags: [event]
comments: false
data: datasaturday{2}
---
"@ -f ($latest + 1), $eventObject.eventname, $newNumber
$mdcontent| Out-File $mdFileName
[string]$rooms = foreach($room in $eventObject.rooms -split ','){
"- name: {0}
url: {1}
" -f ($room -split ';')[0], ($room -split ';')[1]
}
[string]$sponsors = foreach($sponsor in $eventObject.sponsors -split ','){
"- link: {0}
image: {1}
height: {2}
" -f ($sponsor -split ';')[0], ($sponsor -split ';')[1], ($sponsor -split ';')[2]
}
[string]$organisers = foreach($organiser in $eventObject.organizers -split ','){
"- name: {0}
twitter: {1}
email: {2}
" -f ($organiser -split ';')[0], ($organiser -split ';')[1], ($organiser -split ';')[2]
}
$ymlcontent = @"
name: "Data Saturday #{0} - {1}"
date: {2}
description: '
{3}
'
registrationurl: {4}
join:
description: Click on the room you want to join. You can change rooms at any time to attend the sessions that you prefer.
rooms:
{5}
sponsors:
{6}
scheduleurl: {7}
speakerlisturl: {8}
callforspeakers: true
volunteerrequesturl: {9}
organizers:
{10}
"@ -f ($latest + 1), $eventObject.eventname ,$eventObject.date, $eventObject.description, $eventObject.registrationurl, $rooms , $sponsors, $eventObject.scheduleurl, $eventObject.speakerlisturl ,$eventObject.volunteerrequesturl, $organisers
$ymlcontent | Out-File $yamlFileName
shell: pwsh
continue-on-error: true
- name: Add & Commit
uses: EndBug/add-and-commit@v8.0.2
with:
author_name: Beardy McBeardFace
author_email: mrrobsewell@outlook.com
message: 'Added the parsed event file to the repo for issue number #${{ github.event.issue.number }} raised by @${{ github.event.issue.user.login }} ***NO_CI***'
new_branch: 'new-event-issue-${{ github.event.issue.number }}'
push: origin new-event-issue-${{ github.event.issue.number }} --set-upstream --force
continue-on-error: true
- name: pull-request
uses: repo-sync/pull-request@v2
with:
source_branch: 'new-event-issue-${{ github.event.issue.number }}' # If blank, default: triggered branch
destination_branch: "main" # If blank, default: master
pr_title: "Adding a new event for issue number #${{ github.event.issue.number }}" # Title of pull request
pr_body: ":crown: *An automated PR*
For issue number #${{ github.event.issue.number }} raised by @${{ github.event.issue.user.login }}
" # Full markdown support, requires pr_title to be set
pr_reviewer: "SQLDBAWithABeard,SpaghettiDba" # Comma-separated list (no spaces)
pr_assignee: "SQLDBAWithABeard,SpaghettiDba" # Comma-separated list (no spaces)
pr_label: "new-event" # Comma-separated list (no spaces) # Milestone name
github_token: ${{ secrets.GITHUB_TOKEN }}