mirror of
https://github.com/NeoCloud/NeoNetwork
synced 2024-11-18 16:20:43 +08:00
104 lines
3 KiB
YAML
104 lines
3 KiB
YAML
name: Test Your PR
|
|
|
|
on:
|
|
pull_request_target:
|
|
branches: [master]
|
|
|
|
jobs:
|
|
build:
|
|
name: Generate ROA
|
|
runs-on: ubuntu-22.04
|
|
|
|
outputs:
|
|
generate_roa: ${{ steps.generate_roa.outputs.base64 }}
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
ref: ${{ github.event.pull_request.head.sha }}
|
|
fetch-depth: 0
|
|
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
ref: master
|
|
path: trusted_master_head
|
|
fetch-depth: 0
|
|
|
|
- run: |
|
|
git remote add trusted trusted_master_head
|
|
git fetch trusted
|
|
# you shall not change this
|
|
git diff --exit-code --name-status trusted/master ${{github.event.pull_request.head.sha}} ./scripts
|
|
# just in case
|
|
rm -rf scripts && cp -a trusted_master_head/scripts ./
|
|
shell: bash
|
|
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
repository: NeoCloud/NeoNetwork-ROA
|
|
path: generated
|
|
|
|
- uses: actions/setup-python@v5
|
|
with:
|
|
python-version: 3.x
|
|
architecture: x64
|
|
|
|
- run: pip install -r scripts/requirements.txt
|
|
|
|
- run: |
|
|
success=true
|
|
|
|
scripts/generate-roa.sh 2> >(tee ~/buildjob.log >&2) || success=false
|
|
|
|
echo -n "base64=" >> $GITHUB_OUTPUT
|
|
base64 -w0 ~/buildjob.log >> $GITHUB_OUTPUT
|
|
${success}
|
|
shell: bash
|
|
id: generate_roa
|
|
|
|
- run: git -C generated diff README.md
|
|
|
|
- uses: actions/upload-artifact@v4
|
|
with:
|
|
name: generated
|
|
path: generated
|
|
|
|
comment_success:
|
|
needs: [build]
|
|
runs-on: ubuntu-20.04
|
|
if: ${{ always() && contains(needs.build.result, 'success') }}
|
|
steps:
|
|
- uses: actions/github-script@v7
|
|
with:
|
|
github-token: ${{secrets.COMMENT_GITHUB_TOKEN}}
|
|
script: |
|
|
github.rest.issues.createComment({
|
|
issue_number: context.issue.number,
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
body: 'Congratulations! Your pull request passed the check.'
|
|
})
|
|
|
|
comment_failure:
|
|
needs: [build]
|
|
runs-on: ubuntu-20.04
|
|
if: ${{ always() && contains(needs.build.result, 'failure') }}
|
|
steps:
|
|
- shell: bash
|
|
run: |
|
|
echo ${{needs.build.outputs.generate_roa}} | base64 -d | tail > /tmp/buildjob_tail.log || echo 'internal error' >> /tmp/buildjob_tail.log
|
|
|
|
- uses: actions/github-script@v7
|
|
with:
|
|
github-token: ${{secrets.COMMENT_GITHUB_TOKEN}}
|
|
script: |
|
|
const fs = require('fs')
|
|
let l = fs.readFileSync('/tmp/buildjob_tail.log', { encoding: 'utf8', flag: 'r' }).replaceAll("```", "'''")
|
|
github.rest.issues.createComment({
|
|
issue_number: context.issue.number,
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
body: `Your pull request failed the check:\n\`\`\`\n${l.trimEnd()}\n\`\`\``
|
|
})
|
|
|
|
- run: false
|