1
0
Fork 0
mirror of https://github.com/NeoCloud/NeoNetwork synced 2024-11-22 21:20:41 +08:00
NeoNetwork/.github/workflows/test-your-pr.yml
2023-12-05 19:47:43 +08:00

87 lines
2.3 KiB
YAML

name: Test Your PR
on:
pull_request:
branches: [master]
jobs:
build:
name: Generate ROA
runs-on: ubuntu-20.04
outputs:
generate_roa: ${{ steps.generate_roa.outputs.base64 }}
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha }}
- uses: actions/checkout@v2
with:
repository: NeoCloud/NeoNetwork-ROA
path: generated
- uses: actions/setup-python@v2
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@v2
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 | tr -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')
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: fs.readFileSync('/tmp/buildjob_tail.log')
})
- run: false