[Submission]: 123 #43
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Issue Check | |
on: | |
issues: | |
types: | |
- opened | |
- reopened | |
- edited | |
issue_comment: | |
types: | |
- created | |
- edited | |
env: | |
GH_TOKEN: ${{ secrets.GH_TOKEN }} | |
GH_REPO: ${{ secrets.GH_REPO }} | |
jobs: | |
react-to-new-issue: | |
name: Post a comment to new issues | |
if: github.event_name == 'issues' && github.event.action == 'opened' | |
runs-on: ubuntu-latest | |
outputs: | |
comment-id: ${{ steps.comment.outputs.comment-id }} | |
steps: | |
- name: Add comment | |
if: env.ACT == false | |
id: comment | |
uses: peter-evans/create-or-update-comment@v1 | |
with: | |
issue-number: ${{ github.event.issue.number }} | |
body: | | |
Thank you for submitting your plugin. | |
The validation of your submission will start soon. | |
is-revalidation: | |
if: github.event.issue.state == 'open' && github.event_name == 'issue_comment' | |
name: Verify if the comment is a revalidation request | |
runs-on: ubuntu-latest | |
steps: | |
- name: Run /validate command | |
env: | |
COMMENT_BODY: ${{ github.event.comment.body }} | |
run: | | |
command=$(echo "$COMMENT_BODY" | head -1) | |
if [[ $command != "/validate"* ]]; then | |
echo "No /validate command found in first line of the comment \"${command}\", skipping" >> $GITHUB_STEP_SUMMARY | |
exit 1 | |
fi | |
- name: Add reactions | |
if: env.ACT == false | |
uses: peter-evans/create-or-update-comment@v2 | |
with: | |
comment-id: ${{ github.event.comment.id }} | |
reactions: '+1' | |
parse-issue: | |
needs: [ react-to-new-issue, is-revalidation ] | |
if: failure() == false && github.event.issue.state == 'open' | |
name: Ensure Terms of Service are accepted | |
runs-on: ubuntu-latest | |
outputs: | |
accepted: ${{ steps.set-output.outputs.accepted }} | |
steps: | |
- name: Parse issue body | |
id: parse | |
uses: zentered/issue-forms-body-parser@v2.1.1 | |
- name: Find checkbox state | |
id: set-output | |
env: | |
JSON_DATA: ${{ steps.parse.outputs.data }} | |
run: | | |
accepted=$(echo $JSON_DATA | jq -r '.["terms-of-services"].list[0].checked') | |
echo "accepted=$accepted" >> $GITHUB_OUTPUT | |
- name: Validate | |
if: steps.set-output.outputs.accepted == 'null' | |
env: | |
PARSED_DATA: ${{ steps.parse.outputs.data }} | |
run: | | |
# Check if $GITHUB_STEP_SUMMARY exist to avoid the following lines to error when running with act | |
if [[ -w "$GITHUB_STEP_SUMMARY" ]]; then | |
echo "No checkbox for the plugin found in the body of the issue ${{ inputs.issue_number }}" >> $GITHUB_STEP_SUMMARY | |
echo "Is the \"terms-of-services\" field present?" >> $GITHUB_STEP_SUMMARY | |
echo $PARSED_DATA >> $GITHUB_STEP_SUMMARY | |
fi | |
exit 1 | |
plugin-not-accepted: | |
runs-on: ubuntu-latest | |
needs: parse-issue | |
if: always() && needs.parse-issue.outputs.accepted == 'false' # 没有同意服务 | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Render template | |
id: render | |
uses: chuhlomin/render-template@v1.6 | |
with: | |
template: .github/workflows/templates/plugin-not-accepted.md | |
vars: | | |
user: ${{ github.event.issue.user.login}} | |
- name: Add comment | |
if: env.ACT == false | |
uses: peter-evans/create-or-update-comment@v3.0.2 | |
with: | |
comment-id: ${{ needs.react-to-new-issue.outputs.comment-id }} | |
edit-mode: replace | |
issue-number: ${{ github.event.issue.number }} | |
body: ${{ steps.render.outputs.result }} | |
# - name: Remove 'plugin/accepted' label | |
# if: env.ACT == false && contains(github.event.issue.labels.*.name, 'plugin/accepted') | |
# uses: actions/github-script@v6 | |
# with: | |
# script: | | |
# github.rest.issues.removeLabel({ | |
# issue_number: context.issue.number, | |
# owner: context.repo.owner, | |
# repo: context.repo.repo, | |
# name: ["plugin/accepted"] | |
# }) | |
- name: Add 'plugin/not-accepted' label | |
if: env.ACT == false && !contains(github.event.issue.labels.*.name, 'plugin/not-accepted') | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
github.rest.issues.addLabels({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
labels: ["plugin/not-accepted"] | |
}) | |
# plugin-accepted: | |
# runs-on: ubuntu-latest | |
# needs: [ react-to-new-issue, parse-issue ] | |
# if: failure() == false && needs.parse-issue.outputs.accepted == 'true' && !contains(github.event.issue.labels.*.name, 'plugin/accepted') | |
# steps: | |
# - uses: actions/checkout@v3 | |
# - name: Render template | |
# id: render | |
# uses: chuhlomin/render-template@v1.6 | |
# with: | |
# template: .github/workflows/templates/plugin-accepted.md | |
# vars: | | |
# user: ${{ github.event.issue.user.login}} | |
# - name: Add comment | |
# if: env.ACT == false | |
# uses: peter-evans/create-or-update-comment@v2 | |
# with: | |
# comment-id: ${{ needs.react-to-new-issue.outputs.comment-id }} | |
# edit-mode: replace | |
# issue-number: ${{ github.event.issue.number }} | |
# body: ${{ steps.render.outputs.result }} | |
# - name: Remove 'plugin/not-accepted' label | |
# if: env.ACT == false && contains(github.event.issue.labels.*.name, 'plugin/not-accepted') | |
# uses: actions/github-script@v6 | |
# with: | |
# script: | | |
# github.rest.issues.removeLabel({ | |
# issue_number: context.issue.number, | |
# owner: context.repo.owner, | |
# repo: context.repo.repo, | |
# name: ["plugin/not-accepted"] | |
# }) | |
# - name: Add 'plugin/accepted' label | |
# if: env.ACT == false | |
# uses: actions/github-script@v6 | |
# with: | |
# script: | | |
# github.rest.issues.addLabels({ | |
# issue_number: context.issue.number, | |
# owner: context.repo.owner, | |
# repo: context.repo.repo, | |
# labels: ["plugin/accepted"] | |
# }) | |
# plugin-not-found: | |
# runs-on: ubuntu-latest | |
# needs: [ react-to-new-issue, parse-issue ] | |
# if: always() && needs.parse-issue.outputs.accepted == 'null' | |
# steps: | |
# - uses: actions/checkout@v3 | |
# - name: Render template when tos are not found | |
# id: render | |
# uses: chuhlomin/render-template@v1.6 | |
# with: | |
# template: .github/workflows/templates/plugin-not-found.md | |
# - name: Add comment if tos not found | |
# if: env.ACT == false | |
# uses: peter-evans/create-or-update-comment@v2 | |
# with: | |
# comment-id: ${{ needs.react-to-new-issue.outputs.comment-id }} | |
# edit-mode: replace | |
# issue-number: ${{ github.event.issue.number }} | |
# body: ${{ steps.render.outputs.result }} | |
# - name: Mark job as failed | |
# run: exit 1 | |
validate: | |
name: plugin validation | |
needs: parse-issue | |
if: always() && needs.parse-issue.outputs.accepted == 'true' | |
uses: ./.github/workflows/validation.yaml |