[plugin]: alicebot-test1 #7
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: Marketplace Actions | |
on: | |
issues: | |
types: | |
- opened | |
- reopened | |
- edited | |
issue_comment: | |
types: | |
- created | |
- edited | |
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 | |
id: comment | |
uses: peter-evans/create-or-update-comment@v2 | |
with: | |
issue-number: ${{ github.event.issue.number }} | |
body: | | |
感谢你的提交. | |
自动验证将在几分钟内开始. | |
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 | |
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: Parse Issue | |
runs-on: ubuntu-latest | |
env: | |
REPO: ${{ github.repository }} | |
ISSUE_NUM: ${{ github.event.issue.number }} | |
ISSUE_TITLE: ${{ github.event.issue.title }} | |
outputs: | |
module_name: ${{ steps.set-output.outputs.module_name }} | |
pypi_name: ${{ steps.set-output.outputs.pypi_name }} | |
result: ${{ steps.run.outputs.result }} | |
output: ${{ steps.run.outputs.output }} | |
type: ${{ steps.run.outputs.type }} | |
name: ${{ steps.run.outputs.name }} | |
steps: | |
- name: Parse issue body | |
id: parse | |
uses: zentered/issue-forms-body-parser@v1.5.1 | |
- name: Get Inputs | |
id: set-output | |
env: | |
JSON_DATA: ${{ steps.parse.outputs.data }} | |
run: | | |
module_name=$(echo $JSON_DATA | jq -r '.["module-name"].text' ) | |
echo "module_name=$module_name" >> $GITHUB_OUTPUT | |
pypi_name=$(echo $JSON_DATA | jq -r '.["pypi-name"].text' ) | |
echo "pypi_name=$pypi_name" >> $GITHUB_OUTPUT | |
# 启动py脚本环境,并传入module_name,pypi_name,ISSUE_TITLE | |
- uses: actions/checkout@v3.3.0 | |
- name: Setup Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.8' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
- name: Run Python script | |
id: run | |
env: | |
TITLE: ${{ env.ISSUE_TITLE }} | |
PYPI_NAME: ${{ steps.set-output.outputs.pypi_name }} | |
run: | | |
python .github/actions_scripts/parse.py | |
validation-failed: | |
runs-on: ubuntu-latest | |
needs: parse-issue | |
if: needs.parse-issue.outputs.result == 'error' | |
steps: | |
- uses: actions/checkout@v3.3.0 | |
- name: Render template | |
id: render | |
uses: chuhlomin/render-template@v1.6 | |
with: | |
template: .github/workflows/templates/validation-failed.md | |
vars: | | |
validation_output: ${{ needs.parse-issue.outputs.output }} | |
- name: Add comment | |
uses: peter-evans/create-or-update-comment@v3.0.2 | |
with: | |
issue-number: ${{ github.event.issue.number }} | |
body: ${{ steps.render.outputs.result }} | |
- name: Remove label validation/succeeded | |
if: contains(github.event.issue.labels.*.name, 'validation/succeeded') | |
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: ["validation/succeeded"] | |
}) | |
- name: Add label validation/failed | |
if: contains(github.event.issue.labels.*.name, 'validation/failed') == 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: ["validation/failed"] | |
}) | |
- name: Mark job as failed | |
run: exit 1 | |
validation-succeeded: | |
runs-on: ubuntu-latest | |
needs: [parse-issue] | |
if: needs.parse-issue.outputs.result != 'error' | |
steps: | |
- uses: actions/checkout@v3.3.0 | |
- name: Render template | |
id: render | |
uses: chuhlomin/render-template@v1.6 | |
with: | |
template: .github/workflows/templates/validation-succeeded.md | |
vars: | | |
content: ${{ needs.parse-issue.outputs.result }} | |
- name: Add Comment | |
uses: peter-evans/create-or-update-comment@v3.0.2 | |
with: | |
issue-number: ${{ github.event.issue.number }} | |
body: ${{ steps.render.outputs.result }} | |
- name: Remove label validation/failed | |
if: contains(github.event.issue.labels.*.name, 'validation/failed') | |
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: ["validation/failed"] | |
}) | |
- name: Add label validation/succeeded | |
if: contains(github.event.issue.labels.*.name, 'validation/succeeded') == 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: ["validation/succeeded"] | |
}) |