From e9107854abefab74fae9219c074dd3ca061f3bb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Noelia=20Ruiz=20Mart=C3=ADnez?= Date: Sat, 5 Feb 2022 15:51:12 +0100 Subject: [PATCH 01/13] Add ability to send metadata from issues --- .github/ISSUE_TEMPLATE/registerAddon.yml | 35 ++++++++++++ .github/workflows/checkAddonMetadata.yaml | 11 ++++ .github/workflows/sendJsonFile.yaml | 70 +++++++++++++++++++++++ 3 files changed, 116 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/registerAddon.yml create mode 100644 .github/workflows/sendJsonFile.yaml diff --git a/.github/ISSUE_TEMPLATE/registerAddon.yml b/.github/ISSUE_TEMPLATE/registerAddon.yml new file mode 100644 index 00000000000..247b7de8f0e --- /dev/null +++ b/.github/ISSUE_TEMPLATE/registerAddon.yml @@ -0,0 +1,35 @@ +name: Addon registration +description: Add an NVDA add-on to addons-datastore +title: "[Submit add-on]: " +labels: [enhancement] +assignees: +- nvaccess +body: +- type: markdown + attributes: + value: | + Submit an NVDA add-on to datastore. Provide download and source URL, and indicate if it's a stable add-on or not. +- type: input + id: download-url + attributes: + label: Download URL + description: The URL to download the add-on. It must start with https and end with -nvda-addon. + placeholder: https://github.com/username/addon/releases/releaseNumber/download/addonName.nvda-addon + validations: + required: true +- type: input + id: source-url + attributes: + label: Source URL + description: The URL to review the source code of the submitted add-on. + placeholder: https://github.com/username/repo/ + validations: + required: true +- type: checkboxes + id: channel + attributes: + label: Channel + description: Channel for this release (maybe stable or beta) + options: + - label: This is a stable release + required: false diff --git a/.github/workflows/checkAddonMetadata.yaml b/.github/workflows/checkAddonMetadata.yaml index 75a9492e920..6ef4ca4b6fd 100644 --- a/.github/workflows/checkAddonMetadata.yaml +++ b/.github/workflows/checkAddonMetadata.yaml @@ -47,6 +47,17 @@ jobs: } } return addonFileName + - name: Check publisher + uses: actions/github-script@v5 + id: getPublisher + with: + script: | + const diff_url = context.payload.pull_request.diff_url + const result = await github.request(diff_url) + const diff = result.data + if (diff.search(/-\s+"publisher":/) !== -1) { + throw "Publishers don't match" + } - name: Checkout validate repo uses: actions/checkout@v3 with: diff --git a/.github/workflows/sendJsonFile.yaml b/.github/workflows/sendJsonFile.yaml new file mode 100644 index 00000000000..d753b410050 --- /dev/null +++ b/.github/workflows/sendJsonFile.yaml @@ -0,0 +1,70 @@ +name: Send json file + +on: + issues: + types: + - opened + - reopened + - edited + +jobs: + check-addon: + name: Check add-on + runs-on: windows-latest + steps: + - name: Get data + id: get-data + uses: actions/github-script@v5 + with: + script: | + const title = context.payload.issue.title + core.setOutput('title', title) + const number = "#" + context.payload.issue.number + core.setOutput('number', number) + const body = context.payload.issue.body + const downloadUrl = body.split("### Download URL")[1].split("###")[0].trim() + core.setOutput('downloadUrl', downloadUrl) + const sourceUrl = body.split("### Source URL")[1].split("###")[0].trim() + core.setOutput('sourceUrl', sourceUrl) + const releaseChannel = body.split("### Channel")[1].split("###")[0].trim() + if (releaseChannel === "- [x] This is a stable release") { + channel = "stable" + } else { + channel = "beta" + } + core.setOutput('channel', channel) + const publisher = context.payload.sender.login + core.setOutput('publisher', publisher) + - name: Checkout validate repo + uses: actions/checkout@v2 + with: + repository: nvdaes/addon-datastore-validation + submodules: true + - name: Checkout datastore repo + uses: actions/checkout@v2 + with: + repository: nvdaes/addon-datastore + path: datastore + - name: Set up Python 3.8 + uses: actions/setup-python@v2 + with: + python-version: 3.8 + - name: Download add-on + run: curl --location --output addon.nvda-addon ${{ steps.get-data.outputs.downloadUrl }} + - name: Create json file + run: runcreatejson addon.nvda-addon datastore/addons ${{ steps.get-data.outputs.channel }} ${{ steps.get-data.outputs.publisher }} ${{ steps.get-data.outputs.sourceUrl }} ${{ steps.get-data.outputs.downloadUrl }} + shell: cmd + - name: Create Pull Request + id: cpr + uses: peter-evans/create-pull-request@v3 + with: + token: ${{secrets.PR_TOKEN }} + path: datastore + commit-message: ${{ steps.get-data.outputs.title }} + body: Closes issue ${{ steps.get-data.outputs.number }} + - name: Enable Pull Request Automerge + if: steps.cpr.outputs.pull-request-operation == 'created' + uses: peter-evans/enable-pull-request-automerge@v1 + with: + token: ${{ secrets.PR_TOKEN }} + pull-request-number: ${{ steps.cpr.outputs.pull-request-number }} From d57c701cbf83edb481799dae4afcfbf54beb95d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Noelia=20Ruiz=20Mart=C3=ADnez?= Date: Mon, 21 Feb 2022 08:05:58 +0100 Subject: [PATCH 02/13] Throw an error if a submission is changed, even by owners --- .github/workflows/checkAddonMetadata.yaml | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/.github/workflows/checkAddonMetadata.yaml b/.github/workflows/checkAddonMetadata.yaml index 6ef4ca4b6fd..5255ebf6a28 100644 --- a/.github/workflows/checkAddonMetadata.yaml +++ b/.github/workflows/checkAddonMetadata.yaml @@ -40,6 +40,9 @@ jobs: if (Boolean(addonFileName)){ throw "Please submit addon releases individually. One file at a time." } + if (fileData.status === "modified") { + throw "Submitted add-ons cannot be modified" + } addonFileName = filename } else { @@ -47,17 +50,6 @@ jobs: } } return addonFileName - - name: Check publisher - uses: actions/github-script@v5 - id: getPublisher - with: - script: | - const diff_url = context.payload.pull_request.diff_url - const result = await github.request(diff_url) - const diff = result.data - if (diff.search(/-\s+"publisher":/) !== -1) { - throw "Publishers don't match" - } - name: Checkout validate repo uses: actions/checkout@v3 with: From b2401beae40d40da441d0d49ae0e4aa4afcfe050 Mon Sep 17 00:00:00 2001 From: Reef Turner Date: Fri, 22 Jul 2022 15:31:35 +0800 Subject: [PATCH 03/13] handle modified files seperately --- .github/workflows/checkAddonMetadata.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/checkAddonMetadata.yaml b/.github/workflows/checkAddonMetadata.yaml index 5255ebf6a28..75a9492e920 100644 --- a/.github/workflows/checkAddonMetadata.yaml +++ b/.github/workflows/checkAddonMetadata.yaml @@ -40,9 +40,6 @@ jobs: if (Boolean(addonFileName)){ throw "Please submit addon releases individually. One file at a time." } - if (fileData.status === "modified") { - throw "Submitted add-ons cannot be modified" - } addonFileName = filename } else { From 12e5af038ff2a3e57f8d27e12bb23ffe4ab7ad09 Mon Sep 17 00:00:00 2001 From: Reef Turner Date: Fri, 22 Jul 2022 16:54:15 +0800 Subject: [PATCH 04/13] Add extra fields Use NV Access repositories --- .github/ISSUE_TEMPLATE/registerAddon.yml | 41 ++++++++++++++---- .github/workflows/sendJsonFile.yaml | 54 +++++++++++++++--------- 2 files changed, 68 insertions(+), 27 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/registerAddon.yml b/.github/ISSUE_TEMPLATE/registerAddon.yml index 247b7de8f0e..6213f9a7e06 100644 --- a/.github/ISSUE_TEMPLATE/registerAddon.yml +++ b/.github/ISSUE_TEMPLATE/registerAddon.yml @@ -1,10 +1,12 @@ -name: Addon registration -description: Add an NVDA add-on to addons-datastore +name: Add-on registration +description: Add an NVDA add-on to add-ons datastore title: "[Submit add-on]: " labels: [enhancement] assignees: - nvaccess body: +# Docs on using issue forms: +# https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/syntax-for-githubs-form-schema - type: markdown attributes: value: | @@ -13,8 +15,16 @@ body: id: download-url attributes: label: Download URL - description: The URL to download the add-on. It must start with https and end with -nvda-addon. - placeholder: https://github.com/username/addon/releases/releaseNumber/download/addonName.nvda-addon + description: The URL to download the add-on. It must start with 'https' and end with 'nvda-addon'. + placeholder: https://github.com/userName/addonName/releases/releaseNumber/download/addonName.nvda-addon + validations: + required: true +- type: input + id: publisher + attributes: + label: Publisher + description: The author of the addon (individual, group name, or organisation). + placeholder: Author Name validations: required: true - type: input @@ -25,11 +35,26 @@ body: placeholder: https://github.com/username/repo/ validations: required: true -- type: checkboxes +- type: dropdown id: channel attributes: label: Channel - description: Channel for this release (maybe stable or beta) + description: Channel for this add-on release. + multiple: false options: - - label: This is a stable release - required: false + - stable + - beta + validations: + required: true +- type: input + id: license-name + attributes: + label: License Name + description: What license is this add-on released under? + value: GPL v2 +- type: input + id: license-url + attributes: + label: License URL + description: What is the URL to allow reading the license is this add-on released under? + value: https://www.gnu.org/licenses/gpl-2.0.html \ No newline at end of file diff --git a/.github/workflows/sendJsonFile.yaml b/.github/workflows/sendJsonFile.yaml index d753b410050..ce9837b3cd1 100644 --- a/.github/workflows/sendJsonFile.yaml +++ b/.github/workflows/sendJsonFile.yaml @@ -17,33 +17,49 @@ jobs: uses: actions/github-script@v5 with: script: | - const title = context.payload.issue.title - core.setOutput('title', title) - const number = "#" + context.payload.issue.number - core.setOutput('number', number) + // Allow identifying the issue later. + // setOutput exposes the variable for access at later stages via steps.get-data.outputs + // + const issueTitle = context.payload.issue.title + core.setOutput('issueTitle', issueTitle) + const issueNumber = "#" + context.payload.issue.number + core.setOutput('issueNumber', issueNumber) + // Knowing the submitter may be helpful + // const issueSubmitter = context.payload.sender.login + // + // Field headers, Md == Markdown + const header3Prefix = "###" + const dlTitleMd = "### Download URL" + const sourceUrlMd = "### Source URL" + const channelMd = "### Channel" + const licenseMd = "### License Name" + const licenseUrlMd = "### License URL" + const publisherMd = "### Publisher" + // + // collect variables from issue form + // const body = context.payload.issue.body - const downloadUrl = body.split("### Download URL")[1].split("###")[0].trim() + const downloadUrl = body.split(dlTitleMd)[1].split(header3Prefix)[0].trim() core.setOutput('downloadUrl', downloadUrl) - const sourceUrl = body.split("### Source URL")[1].split("###")[0].trim() + const sourceUrl = body.split(sourceUrlMd)[1].split(header3Prefix)[0].trim() core.setOutput('sourceUrl', sourceUrl) - const releaseChannel = body.split("### Channel")[1].split("###")[0].trim() - if (releaseChannel === "- [x] This is a stable release") { - channel = "stable" - } else { - channel = "beta" - } - core.setOutput('channel', channel) - const publisher = context.payload.sender.login + const releaseChannel = body.split(channelMd)[1].split(header3Prefix)[0].trim() + core.setOutput('releaseChannel', releaseChannel) + const publisher = body.split(publisherMd)[1].split(header3Prefix)[0].trim() core.setOutput('publisher', publisher) + const licenseName = body.split(licenseMd)[1].split(header3Prefix)[0].trim() + core.setOutput('licenseName', licenseName) + const licenseUrl = body.split(licenseUrlMd)[1].split(header3Prefix)[0].trim() + core.setOutput('licenseUrl', licenseUrl) - name: Checkout validate repo uses: actions/checkout@v2 with: - repository: nvdaes/addon-datastore-validation + repository: nvaccess/addon-datastore-validation submodules: true - name: Checkout datastore repo uses: actions/checkout@v2 with: - repository: nvdaes/addon-datastore + repository: nvaccess/addon-datastore path: datastore - name: Set up Python 3.8 uses: actions/setup-python@v2 @@ -52,7 +68,7 @@ jobs: - name: Download add-on run: curl --location --output addon.nvda-addon ${{ steps.get-data.outputs.downloadUrl }} - name: Create json file - run: runcreatejson addon.nvda-addon datastore/addons ${{ steps.get-data.outputs.channel }} ${{ steps.get-data.outputs.publisher }} ${{ steps.get-data.outputs.sourceUrl }} ${{ steps.get-data.outputs.downloadUrl }} + run: runcreatejson -f addon.nvda-addon --dir datastore/addons --channel=${{ steps.get-data.outputs.releaseChannel }} --publisher=${{ steps.get-data.outputs.publisher }} --sourceUrl=${{ steps.get-data.outputs.sourceUrl }} --url=${{ steps.get-data.outputs.downloadUrl }} --licName=${{ steps.get-data.outputs.licenseName }} --licUrl=${{ steps.get-data.outputs.licenseUrl }} shell: cmd - name: Create Pull Request id: cpr @@ -60,8 +76,8 @@ jobs: with: token: ${{secrets.PR_TOKEN }} path: datastore - commit-message: ${{ steps.get-data.outputs.title }} - body: Closes issue ${{ steps.get-data.outputs.number }} + commit-message: ${{ steps.get-data.outputs.issueTitle }} + body: Closes issue ${{ steps.get-data.outputs.issueNumber }} - name: Enable Pull Request Automerge if: steps.cpr.outputs.pull-request-operation == 'created' uses: peter-evans/enable-pull-request-automerge@v1 From f41ecb7f2a9561b17ed4b1294b168aeb75f4a0ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Noelia=20Ruiz=20Mart=C3=ADnez?= Date: Sun, 5 Mar 2023 10:18:38 +0100 Subject: [PATCH 05/13] Update workflows, ready for review --- .github/ISSUE_TEMPLATE/registerAddon.yml | 9 +------- .github/workflows/sendJsonFile.yaml | 28 +++++++++++++----------- 2 files changed, 16 insertions(+), 21 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/registerAddon.yml b/.github/ISSUE_TEMPLATE/registerAddon.yml index 6213f9a7e06..e367f64f426 100644 --- a/.github/ISSUE_TEMPLATE/registerAddon.yml +++ b/.github/ISSUE_TEMPLATE/registerAddon.yml @@ -19,14 +19,6 @@ body: placeholder: https://github.com/userName/addonName/releases/releaseNumber/download/addonName.nvda-addon validations: required: true -- type: input - id: publisher - attributes: - label: Publisher - description: The author of the addon (individual, group name, or organisation). - placeholder: Author Name - validations: - required: true - type: input id: source-url attributes: @@ -44,6 +36,7 @@ body: options: - stable - beta + - dev validations: required: true - type: input diff --git a/.github/workflows/sendJsonFile.yaml b/.github/workflows/sendJsonFile.yaml index ce9837b3cd1..c5c066b65ed 100644 --- a/.github/workflows/sendJsonFile.yaml +++ b/.github/workflows/sendJsonFile.yaml @@ -14,7 +14,7 @@ jobs: steps: - name: Get data id: get-data - uses: actions/github-script@v5 + uses: actions/github-script@v6 with: script: | // Allow identifying the issue later. @@ -34,7 +34,6 @@ jobs: const channelMd = "### Channel" const licenseMd = "### License Name" const licenseUrlMd = "### License URL" - const publisherMd = "### Publisher" // // collect variables from issue form // @@ -45,42 +44,45 @@ jobs: core.setOutput('sourceUrl', sourceUrl) const releaseChannel = body.split(channelMd)[1].split(header3Prefix)[0].trim() core.setOutput('releaseChannel', releaseChannel) - const publisher = body.split(publisherMd)[1].split(header3Prefix)[0].trim() - core.setOutput('publisher', publisher) const licenseName = body.split(licenseMd)[1].split(header3Prefix)[0].trim() core.setOutput('licenseName', licenseName) const licenseUrl = body.split(licenseUrlMd)[1].split(header3Prefix)[0].trim() core.setOutput('licenseUrl', licenseUrl) - name: Checkout validate repo - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: repository: nvaccess/addon-datastore-validation submodules: true + path: validation - name: Checkout datastore repo - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: - repository: nvaccess/addon-datastore + repository: nvdaes/addon-datastore + ref: master path: datastore - name: Set up Python 3.8 - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: 3.8 - name: Download add-on run: curl --location --output addon.nvda-addon ${{ steps.get-data.outputs.downloadUrl }} - name: Create json file - run: runcreatejson -f addon.nvda-addon --dir datastore/addons --channel=${{ steps.get-data.outputs.releaseChannel }} --publisher=${{ steps.get-data.outputs.publisher }} --sourceUrl=${{ steps.get-data.outputs.sourceUrl }} --url=${{ steps.get-data.outputs.downloadUrl }} --licName=${{ steps.get-data.outputs.licenseName }} --licUrl=${{ steps.get-data.outputs.licenseUrl }} + run: | + validation\runcreatejson -f addon.nvda-addon --dir datastore\addons --channel=${{ steps.get-data.outputs.releaseChannel }} --publisher=${{ github.event.sender.login }} --sourceUrl=${{ steps.get-data.outputs.sourceUrl }} --url=${{ steps.get-data.outputs.downloadUrl }} --licName="${{ steps.get-data.outputs.licenseName }}" --licUrl=${{ steps.get-data.outputs.licenseURL }} shell: cmd - name: Create Pull Request id: cpr - uses: peter-evans/create-pull-request@v3 + uses: peter-evans/create-pull-request@v4 with: - token: ${{secrets.PR_TOKEN }} + token: ${{secrets.PR_ACCESS_TOKEN }} path: datastore + title: ${{ steps.get-data.outputs.issueTitle }} + branch-suffix: short-commit-hash commit-message: ${{ steps.get-data.outputs.issueTitle }} body: Closes issue ${{ steps.get-data.outputs.issueNumber }} - name: Enable Pull Request Automerge if: steps.cpr.outputs.pull-request-operation == 'created' - uses: peter-evans/enable-pull-request-automerge@v1 + uses: peter-evans/enable-pull-request-automerge@v2 with: - token: ${{ secrets.PR_TOKEN }} + token: ${{ secrets.PR_ACCESS_TOKEN }} pull-request-number: ${{ steps.cpr.outputs.pull-request-number }} From 5abb7fd47e2914862b88ce6699db27df6529ad85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Noelia=20Ruiz=20Mart=C3=ADnez?= Date: Sun, 5 Mar 2023 20:56:00 +0100 Subject: [PATCH 06/13] Branch named as publisherIssueNumber and close issues automatically --- .github/workflows/sendJsonFile.yaml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/sendJsonFile.yaml b/.github/workflows/sendJsonFile.yaml index c5c066b65ed..979a05e6aca 100644 --- a/.github/workflows/sendJsonFile.yaml +++ b/.github/workflows/sendJsonFile.yaml @@ -22,7 +22,7 @@ jobs: // const issueTitle = context.payload.issue.title core.setOutput('issueTitle', issueTitle) - const issueNumber = "#" + context.payload.issue.number + const issueNumber = context.payload.issue.number core.setOutput('issueNumber', issueNumber) // Knowing the submitter may be helpful // const issueSubmitter = context.payload.sender.login @@ -77,12 +77,17 @@ jobs: token: ${{secrets.PR_ACCESS_TOKEN }} path: datastore title: ${{ steps.get-data.outputs.issueTitle }} - branch-suffix: short-commit-hash + branch: ${{ github.event.sender.login }}${{ steps.get-data.outputs.issueNumber }} commit-message: ${{ steps.get-data.outputs.issueTitle }} - body: Closes issue ${{ steps.get-data.outputs.issueNumber }} + body: "Closes issue #${{ steps.get-data.outputs.issueNumber }}" - name: Enable Pull Request Automerge if: steps.cpr.outputs.pull-request-operation == 'created' uses: peter-evans/enable-pull-request-automerge@v2 with: token: ${{ secrets.PR_ACCESS_TOKEN }} pull-request-number: ${{ steps.cpr.outputs.pull-request-number }} + - name: Close Issue + uses: peter-evans/close-issue@v2 + with: + issue-number: ${{ steps.get-data.outputs.issueNumber }} + comment: Auto-closing issue \ No newline at end of file From 4db8518e1a69808960211a49ff6d4931a6452fc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Noelia=20Ruiz=20Mart=C3=ADnez?= Date: Mon, 6 Mar 2023 07:11:11 +0100 Subject: [PATCH 07/13] Address review comments --- .github/ISSUE_TEMPLATE/registerAddon.yml | 4 +- .github/workflows/sendJsonFile.yaml | 47 +++++------------------- getData.js | 33 +++++++++++++++++ 3 files changed, 44 insertions(+), 40 deletions(-) create mode 100644 getData.js diff --git a/.github/ISSUE_TEMPLATE/registerAddon.yml b/.github/ISSUE_TEMPLATE/registerAddon.yml index e367f64f426..bcc17964a67 100644 --- a/.github/ISSUE_TEMPLATE/registerAddon.yml +++ b/.github/ISSUE_TEMPLATE/registerAddon.yml @@ -1,7 +1,7 @@ name: Add-on registration description: Add an NVDA add-on to add-ons datastore title: "[Submit add-on]: " -labels: [enhancement] +labels: [addonSubmission] assignees: - nvaccess body: @@ -49,5 +49,5 @@ body: id: license-url attributes: label: License URL - description: What is the URL to allow reading the license is this add-on released under? + description: The URL for the license of this add-on value: https://www.gnu.org/licenses/gpl-2.0.html \ No newline at end of file diff --git a/.github/workflows/sendJsonFile.yaml b/.github/workflows/sendJsonFile.yaml index 979a05e6aca..507ad3b445b 100644 --- a/.github/workflows/sendJsonFile.yaml +++ b/.github/workflows/sendJsonFile.yaml @@ -12,61 +12,32 @@ jobs: name: Check add-on runs-on: windows-latest steps: + - name: Checkout datastore repo + uses: actions/checkout@v3 + with: + repository: nvdaes/addon-datastore + ref: master + path: datastore - name: Get data id: get-data uses: actions/github-script@v6 with: script: | - // Allow identifying the issue later. - // setOutput exposes the variable for access at later stages via steps.get-data.outputs - // - const issueTitle = context.payload.issue.title - core.setOutput('issueTitle', issueTitle) - const issueNumber = context.payload.issue.number - core.setOutput('issueNumber', issueNumber) - // Knowing the submitter may be helpful - // const issueSubmitter = context.payload.sender.login - // - // Field headers, Md == Markdown - const header3Prefix = "###" - const dlTitleMd = "### Download URL" - const sourceUrlMd = "### Source URL" - const channelMd = "### Channel" - const licenseMd = "### License Name" - const licenseUrlMd = "### License URL" - // - // collect variables from issue form - // - const body = context.payload.issue.body - const downloadUrl = body.split(dlTitleMd)[1].split(header3Prefix)[0].trim() - core.setOutput('downloadUrl', downloadUrl) - const sourceUrl = body.split(sourceUrlMd)[1].split(header3Prefix)[0].trim() - core.setOutput('sourceUrl', sourceUrl) - const releaseChannel = body.split(channelMd)[1].split(header3Prefix)[0].trim() - core.setOutput('releaseChannel', releaseChannel) - const licenseName = body.split(licenseMd)[1].split(header3Prefix)[0].trim() - core.setOutput('licenseName', licenseName) - const licenseUrl = body.split(licenseUrlMd)[1].split(header3Prefix)[0].trim() - core.setOutput('licenseUrl', licenseUrl) + const script = require('./datastore/getData.js') + script({context, core}) - name: Checkout validate repo uses: actions/checkout@v3 with: repository: nvaccess/addon-datastore-validation submodules: true path: validation - - name: Checkout datastore repo - uses: actions/checkout@v3 - with: - repository: nvdaes/addon-datastore - ref: master - path: datastore - name: Set up Python 3.8 uses: actions/setup-python@v4 with: python-version: 3.8 - name: Download add-on run: curl --location --output addon.nvda-addon ${{ steps.get-data.outputs.downloadUrl }} - - name: Create json file + - name: Open submission from issue template run: | validation\runcreatejson -f addon.nvda-addon --dir datastore\addons --channel=${{ steps.get-data.outputs.releaseChannel }} --publisher=${{ github.event.sender.login }} --sourceUrl=${{ steps.get-data.outputs.sourceUrl }} --url=${{ steps.get-data.outputs.downloadUrl }} --licName="${{ steps.get-data.outputs.licenseName }}" --licUrl=${{ steps.get-data.outputs.licenseURL }} shell: cmd diff --git a/getData.js b/getData.js new file mode 100644 index 00000000000..475ada7251a --- /dev/null +++ b/getData.js @@ -0,0 +1,33 @@ +module.exports = ({context, core}) => { + // Allow identifying the issue later. + // setOutput exposes the variable for access at later stages via steps.get-data.outputs + // + const issueTitle = context.payload.issue.title + core.setOutput('issueTitle', issueTitle) + const issueNumber = context.payload.issue.number + core.setOutput('issueNumber', issueNumber) + // Knowing the submitter may be helpful + // const issueSubmitter = context.payload.sender.login + // + // Field headers, Md == Markdown + const header3Prefix = "###" + const dlTitleMd = "### Download URL" + const sourceUrlMd = "### Source URL" + const channelMd = "### Channel" + const licenseMd = "### License Name" + const licenseUrlMd = "### License URL" + // + // collect variables from issue form + // + const body = context.payload.issue.body + const downloadUrl = body.split(dlTitleMd)[1].split(header3Prefix)[0].trim() + core.setOutput('downloadUrl', downloadUrl) + const sourceUrl = body.split(sourceUrlMd)[1].split(header3Prefix)[0].trim() + core.setOutput('sourceUrl', sourceUrl) + const releaseChannel = body.split(channelMd)[1].split(header3Prefix)[0].trim() + core.setOutput('releaseChannel', releaseChannel) + const licenseName = body.split(licenseMd)[1].split(header3Prefix)[0].trim() + core.setOutput('licenseName', licenseName) + const licenseUrl = body.split(licenseUrlMd)[1].split(header3Prefix)[0].trim() + core.setOutput('licenseUrl', licenseUrl) +} \ No newline at end of file From b8074dad3297af4d200468b0198049a9c8c16b26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Noelia=20Ruiz=20Mart=C3=ADnez?= Date: Tue, 7 Mar 2023 08:55:16 +0100 Subject: [PATCH 08/13] Set GitHub Actions as author --- .github/workflows/sendJsonFile.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/sendJsonFile.yaml b/.github/workflows/sendJsonFile.yaml index 507ad3b445b..38b2a8652ec 100644 --- a/.github/workflows/sendJsonFile.yaml +++ b/.github/workflows/sendJsonFile.yaml @@ -51,6 +51,7 @@ jobs: branch: ${{ github.event.sender.login }}${{ steps.get-data.outputs.issueNumber }} commit-message: ${{ steps.get-data.outputs.issueTitle }} body: "Closes issue #${{ steps.get-data.outputs.issueNumber }}" + author: github-actions - name: Enable Pull Request Automerge if: steps.cpr.outputs.pull-request-operation == 'created' uses: peter-evans/enable-pull-request-automerge@v2 From c38acf0f892a1988e1cefe7dfb06a8609c6153b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Noelia=20Ruiz=20Mart=C3=ADnez?= Date: Tue, 7 Mar 2023 08:58:39 +0100 Subject: [PATCH 09/13] Change label to autoSubmissionFromIssue --- .github/ISSUE_TEMPLATE/registerAddon.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/registerAddon.yml b/.github/ISSUE_TEMPLATE/registerAddon.yml index bcc17964a67..0448dd076e3 100644 --- a/.github/ISSUE_TEMPLATE/registerAddon.yml +++ b/.github/ISSUE_TEMPLATE/registerAddon.yml @@ -1,7 +1,7 @@ name: Add-on registration description: Add an NVDA add-on to add-ons datastore title: "[Submit add-on]: " -labels: [addonSubmission] +labels: [autoSubmissionFromIssue] assignees: - nvaccess body: From 092de4fed1cfdb0b87a01dcb44e12c719ad7d921 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Noelia=20Ruiz=20Mart=C3=ADnez?= Date: Tue, 7 Mar 2023 09:02:41 +0100 Subject: [PATCH 10/13] Change to suggested name for step --- .github/workflows/sendJsonFile.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sendJsonFile.yaml b/.github/workflows/sendJsonFile.yaml index 38b2a8652ec..5ded1d55fe6 100644 --- a/.github/workflows/sendJsonFile.yaml +++ b/.github/workflows/sendJsonFile.yaml @@ -37,7 +37,7 @@ jobs: python-version: 3.8 - name: Download add-on run: curl --location --output addon.nvda-addon ${{ steps.get-data.outputs.downloadUrl }} - - name: Open submission from issue template + - name: Create JSON submission from issue run: | validation\runcreatejson -f addon.nvda-addon --dir datastore\addons --channel=${{ steps.get-data.outputs.releaseChannel }} --publisher=${{ github.event.sender.login }} --sourceUrl=${{ steps.get-data.outputs.sourceUrl }} --url=${{ steps.get-data.outputs.downloadUrl }} --licName="${{ steps.get-data.outputs.licenseName }}" --licUrl=${{ steps.get-data.outputs.licenseURL }} shell: cmd From f8ee65ef7e52c56857a3aae3c0b7ce2de0c2908b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Noelia=20Ruiz=20Mart=C3=ADnez?= Date: Tue, 7 Mar 2023 09:33:46 +0100 Subject: [PATCH 11/13] Address review --- .github/ISSUE_TEMPLATE/registerAddon.yml | 2 +- getData.js => .github/workflows/getData.js | 0 .github/workflows/sendJsonFile.yaml | 7 ++++--- 3 files changed, 5 insertions(+), 4 deletions(-) rename getData.js => .github/workflows/getData.js (100%) diff --git a/.github/ISSUE_TEMPLATE/registerAddon.yml b/.github/ISSUE_TEMPLATE/registerAddon.yml index 0448dd076e3..252c6f35d44 100644 --- a/.github/ISSUE_TEMPLATE/registerAddon.yml +++ b/.github/ISSUE_TEMPLATE/registerAddon.yml @@ -50,4 +50,4 @@ body: attributes: label: License URL description: The URL for the license of this add-on - value: https://www.gnu.org/licenses/gpl-2.0.html \ No newline at end of file + value: https://www.gnu.org/licenses/gpl-2.0.html diff --git a/getData.js b/.github/workflows/getData.js similarity index 100% rename from getData.js rename to .github/workflows/getData.js diff --git a/.github/workflows/sendJsonFile.yaml b/.github/workflows/sendJsonFile.yaml index 5ded1d55fe6..96ef221d4b6 100644 --- a/.github/workflows/sendJsonFile.yaml +++ b/.github/workflows/sendJsonFile.yaml @@ -10,6 +10,7 @@ on: jobs: check-addon: name: Check add-on + if: contains(github.event.issues.labels.*.name, 'autoSubmissionFromIssue') runs-on: windows-latest steps: - name: Checkout datastore repo @@ -23,8 +24,8 @@ jobs: uses: actions/github-script@v6 with: script: | - const script = require('./datastore/getData.js') - script({context, core}) + const setOutputFromIssue = require('./datastore/.github/workflows/getData.js') + setOutputFromIssue({context, core}) - name: Checkout validate repo uses: actions/checkout@v3 with: @@ -62,4 +63,4 @@ jobs: uses: peter-evans/close-issue@v2 with: issue-number: ${{ steps.get-data.outputs.issueNumber }} - comment: Auto-closing issue \ No newline at end of file + comment: Auto-closing issue From d57462c3e7dee22dc8ffd3e39f544e7c2cedfd50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Noelia=20Ruiz=20Mart=C3=ADnez?= Date: Tue, 7 Mar 2023 10:34:02 +0100 Subject: [PATCH 12/13] Use labeled event for issues --- .github/workflows/sendJsonFile.yaml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/sendJsonFile.yaml b/.github/workflows/sendJsonFile.yaml index 96ef221d4b6..08feb1e33a1 100644 --- a/.github/workflows/sendJsonFile.yaml +++ b/.github/workflows/sendJsonFile.yaml @@ -3,14 +3,12 @@ name: Send json file on: issues: types: - - opened - - reopened - - edited + - labeled jobs: check-addon: name: Check add-on - if: contains(github.event.issues.labels.*.name, 'autoSubmissionFromIssue') + if: github.event.label.name == 'autoSubmissionFromIssue' runs-on: windows-latest steps: - name: Checkout datastore repo From 2a50a39126a7ed78d713f138d8cfb86fca3a55c6 Mon Sep 17 00:00:00 2001 From: Sean Budd Date: Wed, 8 Mar 2023 07:21:00 +1100 Subject: [PATCH 13/13] Apply suggestions from code review --- .github/ISSUE_TEMPLATE/registerAddon.yml | 2 +- .github/workflows/getData.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/registerAddon.yml b/.github/ISSUE_TEMPLATE/registerAddon.yml index 252c6f35d44..9f882e248ef 100644 --- a/.github/ISSUE_TEMPLATE/registerAddon.yml +++ b/.github/ISSUE_TEMPLATE/registerAddon.yml @@ -15,7 +15,7 @@ body: id: download-url attributes: label: Download URL - description: The URL to download the add-on. It must start with 'https' and end with 'nvda-addon'. + description: The URL to download the add-on. It must start with 'https' and end with 'nvda-addon'. This URL should always download the same file of the same add-on version. placeholder: https://github.com/userName/addonName/releases/releaseNumber/download/addonName.nvda-addon validations: required: true diff --git a/.github/workflows/getData.js b/.github/workflows/getData.js index 475ada7251a..e43fb896604 100644 --- a/.github/workflows/getData.js +++ b/.github/workflows/getData.js @@ -30,4 +30,4 @@ module.exports = ({context, core}) => { core.setOutput('licenseName', licenseName) const licenseUrl = body.split(licenseUrlMd)[1].split(header3Prefix)[0].trim() core.setOutput('licenseUrl', licenseUrl) -} \ No newline at end of file +}