-
Notifications
You must be signed in to change notification settings - Fork 215
169 lines (165 loc) · 5.85 KB
/
postaction.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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
name: PostAction
on:
workflow_run:
workflows: ["Regression"]
types:
- completed
jobs:
job2:
runs-on: ubuntu-latest
if: >
${{ github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.conclusion == 'success' }}
outputs:
output_id_number: ${{ steps.step1.outputs.id }}
steps:
- name: 'Download artifact'
uses: actions/github-script@v3.1.0
with:
script: |
console.log(${{ github.event.workflow_run.id }});
var artifacts = await github.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: ${{ github.event.workflow_run.id }},
});
var matchArtifact = artifacts.data.artifacts.filter((artifact) => {
return artifact.name == "share_info";
})[0];
var download = await github.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip',
});
var fs = require('fs');
fs.writeFileSync('${{ github.workspace }}/share_info.zip', Buffer.from(download.data));
- run: unzip share_info.zip
- run: |
echo "university=$(cat university.txt)" >> $GITHUB_ENV
echo "assignment=$(cat assignment_number.txt)" >> $GITHUB_ENV
echo "login=$(cat gitid.txt)" >> $GITHUB_ENV
echo "base=$(cat base.txt)" >> $GITHUB_ENV
- name: Check Deadline
run: |
deadlines_CUB=(
"2024-02-19T23:59"
"2024-02-19T23:59"
"2024-02-19T23:59"
"2024-03-04T23:59"
"2024-03-04T23:59"
"2024-03-11T23:59"
"2024-04-08T23:59"
"2024-04-15T23:59"
"2024-06-01T23:59"
"2024-06-01T23:59"
)
deadlines_NUP=(
"2024-03-04T23:59"
"2024-03-04T23:59"
"2024-03-04T23:59"
"2024-03-11T23:59"
"2024-04-04T23:59"
"2024-04-15T23:59"
"2024-04-15T23:59"
"2024-06-01T23:59"
"2024-06-01T23:59"
"2024-06-01T23:59"
)
deadlines_SPBGU=(
"2024-03-06T23:59"
"2024-03-13T23:59"
"2024-03-20T23:59"
"2024-03-27T23:59"
"2024-04-03T23:59"
"2024-04-10T23:59"
"2024-04-17T23:59"
"2024-04-24T23:59"
"2024-05-01T23:59"
"2024-05-08T23:59"
"2024-05-15T23:59"
"2024-05-22T23:59"
)
if [[ "CUB" == $university ]]; then
deadline=${deadlines_CUB[${assignment_number}-1]}
elif [[ "NUP" == $university ]]; then
deadline=${deadlines_NUP[${assignment_number}-1]}
elif [[ "SPBGU" == $university ]]; then
deadline=${deadlines_SPBGU[${assignment_number}-1]}
else
echo "FIASCO: Wrong university name"
exit 1
fi
echo "Deadline for $university for assignment number $assignment_number is $deadline "
if [[ $(date +'%Y-%m-%d') > $deadline ]]; then
echo "FIASCO: The deadline has expired"
exit 1
fi
echo "OK: you are on time!"
# - name: Check out code
# uses: actions/checkout@v2
# - name: Comment PR
# uses: thollander/actions-comment-pull-request@v2
# with:
# message: |
# All checks have successfully passed!
# The assignment is submitted on time.
# reactions: rocket
- id: 'get_worksheet'
uses: jroehl/gsheet.action@v1.0.0
with:
spreadsheetId: ${{secrets.SPREADSHEET_ID}}
commands: | # list of commands, specified as a valid JSON string
[
{ "command": "getData", "args": { "worksheetTitle": "Sheet1", "minCol": 1, "maxCol": 1 } }
]
env:
GSHEET_CLIENT_EMAIL: ${{ secrets.SERVICE_EMAIL }}
GSHEET_PRIVATE_KEY: ${{ secrets.SERVICE_KEY }}
- id: step1
name: dump results
env:
# the output of the action can be found in ${{ steps.update_worksheet.outputs.results }}
RESULTS: ${{ steps.get_worksheet.outputs.results }}
run: |
cmd=$(echo "${RESULTS}" | jq ".results[0].result.rawData")
branch=${{ env.base }}
assignment=${{ env.assignment }}
gitid="\"${{ env.login }}\""
result=1
j=0
for i in {1..200}
do
t=$(echo "${cmd}" | jq ".[$i][0]")
echo "$t"
echo "$gitid"
if [ "$t" = "$gitid" ]; then
echo "FOUND"
echo "$i"
j="[{ \"command\": \"updateData\", \"args\": {\"worksheetTitle\": \"Sheet1\", \"data\": [["\"$result\"", "\"$result\""]], \"minCol\": $((assignment*2)), \"minRow\": $((i+1)) }} ]"
echo "$j"
echo "::set-output name=id::$j"
else
echo "Strings are not equal."
fi
done
if [[ $j -eq 0 ]]
then
j="[{ \"command\": \"appendData\", \"args\": {\"worksheetTitle\": \"Sheet1\", \"data\": [["$gitid", "\"$result\"", "\"$result\""]], \"minCol\": 1 }} ]"
echo "::set-output name=id::$j"
fi
echo $j
echo "$gitid"
# echo "::set-output name=id::$i"
job3:
runs-on: ubuntu-latest
needs: job2
steps:
- id: 'update_worksheet'
uses: jroehl/gsheet.action@v1.0.0
with:
spreadsheetId: ${{secrets.SPREADSHEET_ID}}
commands: ${{needs.job2.outputs.output_id_number}}
env:
GSHEET_CLIENT_EMAIL: ${{ secrets.SERVICE_EMAIL }}
GSHEET_PRIVATE_KEY: ${{ secrets.SERVICE_KEY }}