|
| 1 | +name: gsheet.action test |
| 2 | +on: # [push] |
| 3 | + # pull_request: |
| 4 | + pull_request_target: |
| 5 | + types: [opened, reopened, edited] |
| 6 | + |
| 7 | +jobs: |
| 8 | + job1: |
| 9 | + runs-on: ubuntu-latest |
| 10 | + # Map a step output to a job output |
| 11 | + outputs: |
| 12 | + output_id: ${{ steps.step1.outputs.id }} |
| 13 | + output_result: ${{ steps.step1.outputs.res }} |
| 14 | + steps: |
| 15 | + - uses: actions/checkout@v2 |
| 16 | + with: |
| 17 | +# fetch-depth: 2 |
| 18 | +# ref: ${{ github.head_ref }} |
| 19 | + ref: refs/pull/${{ github.event.pull_request.number }}/head |
| 20 | + - id: step1 |
| 21 | + run: | |
| 22 | + cd seminar02 |
| 23 | + re=$(python3 checker.py) |
| 24 | + echo "$re" |
| 25 | + echo "::set-output name=res::$re" |
| 26 | + login=${{ github.event.pull_request.user.login }} |
| 27 | + echo "$login" |
| 28 | + echo "::set-output name=id::\"$login\"" |
| 29 | +# echo "::set-output name=id::\"$(git log --perl-regexp --author='^((?!danyaberezun).*)$' -1 --pretty=format:'%an')\"" |
| 30 | + job2: |
| 31 | + runs-on: ubuntu-latest |
| 32 | + needs: job1 |
| 33 | + outputs: |
| 34 | + output_id_number: ${{ steps.step1.outputs.id }} |
| 35 | + steps: |
| 36 | + - id: 'get_worksheet' |
| 37 | + uses: jroehl/gsheet.action@v1.0.0 |
| 38 | + with: |
| 39 | + spreadsheetId: ${{secrets.SPREADSHEET_ID}} |
| 40 | + commands: | # list of commands, specified as a valid JSON string |
| 41 | + [ |
| 42 | + { "command": "getData", "args": { "worksheetTitle": "Sheet1", "minCol": 1, "maxCol": 1 } } |
| 43 | + ] |
| 44 | + env: |
| 45 | + GSHEET_CLIENT_EMAIL: ${{ secrets.SERVICE_EMAIL }} |
| 46 | + GSHEET_PRIVATE_KEY: ${{ secrets.SERVICE_KEY }} |
| 47 | + - id: step1 |
| 48 | + name: dump results |
| 49 | + env: |
| 50 | + # the output of the action can be found in ${{ steps.update_worksheet.outputs.results }} |
| 51 | + RESULTS: ${{ steps.get_worksheet.outputs.results }} |
| 52 | + run: | |
| 53 | + cmd=$(echo "${RESULTS}" | jq ".results[0].result.rawData") |
| 54 | + gitid=\"${{needs.job1.outputs.output_id}}\" |
| 55 | + result=\"${{needs.job1.outputs.output_result}}\" |
| 56 | + j=0 |
| 57 | + for i in {1..60} |
| 58 | + do |
| 59 | + t=$(echo "${cmd}" | jq ".[$i][0]") |
| 60 | + echo "$t" |
| 61 | + echo "$gitid" |
| 62 | + if [ "$t" = "$gitid" ]; then |
| 63 | + echo "FOUND" |
| 64 | + echo "$i" |
| 65 | + j="[{ \"command\": \"updateData\", \"args\": {\"worksheetTitle\": \"Sheet1\", \"data\": [["$result", "$result"]], \"minCol\": 2, \"minRow\": $((i+1)) }} ]" |
| 66 | + echo "$j" |
| 67 | + echo "::set-output name=id::$j" |
| 68 | + else |
| 69 | + echo "Strings are not equal." |
| 70 | + fi |
| 71 | + done |
| 72 | + if [[ $j -eq 0 ]] |
| 73 | + then |
| 74 | + j="[{ \"command\": \"appendData\", \"args\": {\"worksheetTitle\": \"Sheet1\", \"data\": [["$gitid", "$result", "$result"]], \"minCol\": 1 }} ]" |
| 75 | + echo "::set-output name=id::$j" |
| 76 | + fi |
| 77 | + echo $j |
| 78 | + echo "$gitid" |
| 79 | +# echo "::set-output name=id::$i" |
| 80 | + job3: |
| 81 | + runs-on: ubuntu-latest |
| 82 | + needs: job2 |
| 83 | + steps: |
| 84 | + - id: 'update_worksheet' |
| 85 | + uses: jroehl/gsheet.action@v1.0.0 |
| 86 | + with: |
| 87 | + spreadsheetId: ${{secrets.SPREADSHEET_ID}} |
| 88 | + commands: ${{needs.job2.outputs.output_id_number}} |
| 89 | + env: |
| 90 | + GSHEET_CLIENT_EMAIL: ${{ secrets.SERVICE_EMAIL }} |
| 91 | + GSHEET_PRIVATE_KEY: ${{ secrets.SERVICE_KEY }} |
0 commit comments