Skip to content

Create SydTek_Milestone3.md #1490

Create SydTek_Milestone3.md

Create SydTek_Milestone3.md #1490

name: Google Sheet Update
on:
pull_request_target:
types: [opened, synchronize]
jobs:
get-delivery-files:
runs-on: ubuntu-latest
outputs:
filenames: ${{ steps.files.outputs.added }}
steps:
- name: Get filenames of any deliveries being added
id: files
uses: Ana06/[email protected]
with:
format: 'json'
filter: |
deliveries/*.md
maintenance_deliveries/*.md
check-no-success:
needs: get-delivery-files
runs-on: ubuntu-latest
outputs:
has-succeeded: ${{ steps.check-no-success.outputs.has-succeeded }}
steps:
- name: Check that the workflow didn't yet run successfully in this PR
uses: actions/github-script@v5
id: check-no-success
if: needs.get-delivery-files.outputs.filenames != '[]'
with:
script: |
// https://octokit.github.io/rest.js/v18
const runs = await github.rest.actions.listWorkflowRuns({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: 'google_sheet_update.yml',
status: 'success',
per_page: 100
});
const pr_commits = await github.rest.pulls.listCommits({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: ${{ github.event.number }},
per_page: 100
});
const runs_shas = runs.data.workflow_runs.map(run => {return run.head_sha});
const pr_shas = pr_commits.data.map(c => {return c.sha});
core.setOutput("has-succeeded", pr_shas.filter(s => runs_shas.includes(s)).length != 0);
update-sheet:
needs: [ get-delivery-files, check-no-success ]
if: needs.get-delivery-files.outputs.filenames != '[]' && needs.check-no-success.outputs.has-succeeded == 'false'
runs-on: ubuntu-latest
strategy:
max-parallel: 1
fail-fast: false
matrix:
filename: ${{ fromJson(needs.get-delivery-files.outputs.filenames) }}
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Parse delivery file
id: parse-delivery
uses: w3f/parse-milestone-delivery-action@v3
with:
path: "${{ github.workspace }}/${{ matrix.filename }}"
- name: Get application file
run: wget "https://raw.githubusercontent.com/w3f/Grants-Program/master/applications/${{ steps.parse-delivery.outputs.application_document }}"
- name: Parse application file
id: parse-grant
uses: w3f/parse-grant-application-action@v1
with:
path: "${{ steps.parse-delivery.outputs.application_document }}"
- name: Get current date
id: date
run: echo "::set-output name=date::$(date +'%d/%m/%Y')"
- name: Write data to sheet
uses: jroehl/[email protected]
with:
spreadsheetId: ${{ secrets.SPREADSHEET_ID }}
commands: |
[
{
"command": "appendData",
"args":
{
"data": [[
"=IFERROR(HYPERLINK(\"#gid=0&range=\" & MATCH(INDIRECT(CONCATENATE(\"B\", TEXT(ROW(), \"#\"))), Legal!$D:$D, 0) & \":\" & MATCH(INDIRECT(CONCATENATE(\"B\", TEXT(ROW(), \"#\"))), Legal!$D:$D, 0), INDEX(Legal!$A$2:$A,MATCH(INDIRECT(CONCATENATE(\"B\", TEXT(ROW(), \"#\"))),Legal!$D$2:$D,0))), \"\")",
"${{ steps.parse-grant.outputs.project_name }}",
"${{ steps.parse-delivery.outputs.milestone_number }}",
"",
"Not Yet",
"=IFERROR(SWITCH(INDIRECT(ADDRESS(ROW(),COLUMN()-1)), \"Not Yet\", 4, \"In Progress\", 3, \"Asked for Changes\", 2, \"Final Check\", 3, \"Final Warning\", 3, \"Done\", 0, \"Terminated\", 0, \"On Hold\", 1))",
"=INDEX(Legal!$W$2:$W,MATCH(INDIRECT(CONCATENATE(\"B\", TEXT(ROW(), \"#\"))),Legal!$D$2:$D,0))",
"${{ github.event.pull_request.html_url }}",
"",
"${{ steps.date.outputs.date }}"
]],
"worksheetTitle": "Evaluation",
"minCol": 1,
"valueInputOption": "USER_ENTERED"
}
}
]
env:
GSHEET_CLIENT_EMAIL: ${{ secrets.GSHEET_CLIENT_EMAIL }}
GSHEET_PRIVATE_KEY: ${{ secrets.GSHEET_PRIVATE_KEY }}