Skip to content

Commit

Permalink
Merge pull request #9 from 0xCaso/master
Browse files Browse the repository at this point in the history
Improvements
  • Loading branch information
Noc2 authored Feb 15, 2023
2 parents 2db6e08 + 9bf9e48 commit 302c518
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 14 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,17 @@ jobs:
npm run build
- name: Get example (well formed) applications
run: |
mkdir applications;
mkdir maintenance;
cd applications;
wget "https://raw.githubusercontent.com/w3f/Grants-Program/master/applications/AdMeta.md";
cd ../maintenance;
wget "https://raw.githubusercontent.com/w3f/Grants-Program/master/maintenance/wasm-opt-for-rust.md"
- name: Test action with normal application
uses: ./
with:
path: AdMeta.md
path: applications/AdMeta.md
- name: Test action with maintenance application
uses: ./
with:
path: wasm-opt-for-rust.md
path: maintenance/wasm-opt-for-rust.md
24 changes: 18 additions & 6 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2877,6 +2877,7 @@ const main = async () => {

let error_not_found = [];
let warning_not_found = [];
let outputs = [];

regexList.map(function (reg) {
try {
Expand All @@ -2886,29 +2887,29 @@ const main = async () => {
if (project_name === 'W3F Grant Proposal' || project_name === 'Name of your Project' || project_name === 'W3F Maintenance Grant Proposal') {
core.setFailed(`Project name is the default one. Please change it.`)
} else {
core.setOutput(reg.name, project_name)
outputs.push({name: reg.name, value: project_name})
}
break
case 'total_cost_dai':
if (!is_maintenance) {
// take only the numbers removing extra strings like $, USD, DAI...
let total_cost_dai = content.match(reg.regex)[0].match(/\d+/g).join('')
core.setOutput(reg.name, total_cost_dai)
outputs.push({name: reg.name, value: total_cost_dai})
} else {
core.setOutput(reg.name, 0)
outputs.push({name: reg.name, value: "0"})
}
break
case 'total_milestones':
if (!is_maintenance) {
const milestones = content.match(reg.regex)
core.setOutput(reg.name, milestones.length)
outputs.push({name: reg.name, value: milestones.length+""}) // convert to string
} else {
core.setOutput(reg.name, 0)
outputs.push({name: reg.name, value: "0"})
}
break
default:
const result = content.match(reg.regex)[0]
core.setOutput(reg.name, result)
outputs.push({name: reg.name, value: result})
}
} catch {
if (reg.mandatory) {
Expand All @@ -2928,6 +2929,17 @@ const main = async () => {
const error_string = error_not_found.join(', ')
core.setFailed(`Mandatory fields missing: ${error_string}`)
}

// if setted outputs are in the form [output](link), take only "output"
outputs.map(function (out) {
if (out.value.includes('](')) {
let output = out.value.split('](')[0].replace('[', '')
core.setOutput(out.name, output)
} else {
core.setOutput(out.name, out.value)
}
})

}

main().catch(err => core.setFailed(err.message))
Expand Down
24 changes: 18 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ const main = async () => {

let error_not_found = [];
let warning_not_found = [];
let outputs = [];

regexList.map(function (reg) {
try {
Expand All @@ -66,29 +67,29 @@ const main = async () => {
if (project_name === 'W3F Grant Proposal' || project_name === 'Name of your Project' || project_name === 'W3F Maintenance Grant Proposal') {
core.setFailed(`Project name is the default one. Please change it.`)
} else {
core.setOutput(reg.name, project_name)
outputs.push({name: reg.name, value: project_name})
}
break
case 'total_cost_dai':
if (!is_maintenance) {
// take only the numbers removing extra strings like $, USD, DAI...
let total_cost_dai = content.match(reg.regex)[0].match(/\d+/g).join('')
core.setOutput(reg.name, total_cost_dai)
outputs.push({name: reg.name, value: total_cost_dai})
} else {
core.setOutput(reg.name, 0)
outputs.push({name: reg.name, value: "0"})
}
break
case 'total_milestones':
if (!is_maintenance) {
const milestones = content.match(reg.regex)
core.setOutput(reg.name, milestones.length)
outputs.push({name: reg.name, value: milestones.length+""}) // convert to string
} else {
core.setOutput(reg.name, 0)
outputs.push({name: reg.name, value: "0"})
}
break
default:
const result = content.match(reg.regex)[0]
core.setOutput(reg.name, result)
outputs.push({name: reg.name, value: result})
}
} catch {
if (reg.mandatory) {
Expand All @@ -108,6 +109,17 @@ const main = async () => {
const error_string = error_not_found.join(', ')
core.setFailed(`Mandatory fields missing: ${error_string}`)
}

// if setted outputs are in the form [output](link), take only "output"
outputs.map(function (out) {
if (out.value.includes('](')) {
let output = out.value.split('](')[0].replace('[', '')
core.setOutput(out.name, output)
} else {
core.setOutput(out.name, out.value)
}
})

}

main().catch(err => core.setFailed(err.message))

0 comments on commit 302c518

Please sign in to comment.