.github/workflows/postaction.yml #2166
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/[email protected] | |
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/[email protected] | |
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/[email protected] | |
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 }} |