Skip to content

Commit

Permalink
Revert "Parse multiple delivery files (#460)" (#462)
Browse files Browse the repository at this point in the history
This reverts commit b8f870d.
  • Loading branch information
alxs authored Jun 14, 2022
1 parent 5a6e234 commit 870296e
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 66 deletions.
32 changes: 5 additions & 27 deletions .github/workflows/check_author.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,17 @@ on:
types: [opened]

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/get-changed-files@v2.0.0
with:
format: 'json'
filter: 'deliveries/*.md'

check_author:
runs-on: ubuntu-latest
needs: get-delivery-files
if: needs.get-delivery-files.outputs.filenames != '[]'
strategy:
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: Parse delivery file
id: delivery
uses: ./.github/workflows/composite/get_delivery

- name: Find PR author in application authors
if: steps.delivery.outputs.filenames
uses: actions/github-script@v5
env:
pr_author: ${{ github.event.pull_request.user.login }}
Expand All @@ -45,7 +23,7 @@ jobs:
await github.rest.repos.listCommits({
owner: 'w3f',
repo: 'Grants-Program',
path: 'applications/${{ steps.parse-delivery.outputs.application_document }}'
path: 'applications/${{ steps.delivery.outputs.application-filename }}'
}).then( app_commits => {
app_authors = app_commits.data.map(c => {return c.author.login});
if(!app_authors.includes(process.env.pr_author))
Expand Down
33 changes: 33 additions & 0 deletions .github/workflows/composite/get_delivery/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Parse Delivery
outputs:
filenames:
description: Filenames of all delivery documents
value: ${{ steps.files.outputs.added }}
milestone-number:
description: Milestone number
value: ${{ steps.parse-delivery.outputs.milestone_number }}
application-filename:
description: Filename of the application document
value: ${{ steps.parse-delivery.outputs.application_document }}

runs:
using: "composite"
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Get filenames of any deliveries being added
id: files
uses: Ana06/get-changed-files@v2.0.0
with:
filter: 'deliveries/*.md'

- name: Parse delivery file # TODO parse all files separately if there are multiple
if: steps.files.outputs.added
id: parse-delivery
uses: w3f/parse-milestone-delivery-action@v3
with:
path: "${{ github.workspace }}/${{ steps.files.outputs.added }}"

- uses: actions/checkout@v2 # Return to master branch (otherwise the composite action fails)
58 changes: 19 additions & 39 deletions .github/workflows/google_sheet_update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,25 @@ 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/get-changed-files@v2.0.0
with:
format: 'json'
filter: 'deliveries/*.md'

check-no-success:
needs: get-delivery-files
jobs:
get-delivery-once:
runs-on: ubuntu-latest
outputs:
has-succeeded: ${{ steps.check-no-success.outputs.has-succeeded }}

filenames: ${{ steps.delivery.outputs.filenames }}
milestone-number: ${{ steps.delivery.outputs.milestone-number }}
application-filename: ${{ steps.delivery.outputs.application-filename }}
steps:
- uses: actions/checkout@v2

- name: Parse delivery file
id: delivery
uses: ./.github/workflows/composite/get_delivery

- 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 != '[]'
if: steps.delivery.outputs.filenames
with:
script: |
// https://octokit.github.io/rest.js/v18
Expand All @@ -48,34 +42,20 @@ jobs:
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'
update-sheet: # TODO run for each delivery if PR contains more than one (see also get_delivery.yml)
needs: get-delivery-once
if: needs.get-delivery-once.outputs.filenames && needs.get-delivery-once.outputs.has-succeeded == 'false'
runs-on: ubuntu-latest
strategy:
max-parallel: 1
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 }}"
run: wget "https://raw.githubusercontent.com/w3f/Grants-Program/master/applications/${{ needs.get-delivery-once.outputs.application-filename }}"

- name: Parse application file
id: parse-grant
uses: w3f/parse-grant-application-action@v1
with:
path: "${{ steps.parse-delivery.outputs.application_document }}"
path: "${{ needs.get-delivery-once.outputs.application-filename }}"

- name: Get current date
id: date
run: echo "::set-output name=date::$(date +'%d/%m/%Y')"
Expand All @@ -93,7 +73,7 @@ jobs:
"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 }}",
"${{ needs.get-delivery-once.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))",
Expand Down

0 comments on commit 870296e

Please sign in to comment.