2020-05-01 17:45:30 +08:00
|
|
|
name: Test Your PR
|
|
|
|
|
|
|
|
on:
|
2023-12-05 20:54:06 +08:00
|
|
|
pull_request_target:
|
2020-07-21 00:40:22 +08:00
|
|
|
branches: [master]
|
2020-05-01 17:45:30 +08:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
build:
|
|
|
|
name: Generate ROA
|
2020-06-04 11:53:59 +08:00
|
|
|
runs-on: ubuntu-20.04
|
2020-05-01 17:45:30 +08:00
|
|
|
|
2023-12-05 19:29:55 +08:00
|
|
|
outputs:
|
|
|
|
generate_roa: ${{ steps.generate_roa.outputs.base64 }}
|
|
|
|
|
2020-05-01 17:45:30 +08:00
|
|
|
steps:
|
2023-12-05 20:54:06 +08:00
|
|
|
- uses: actions/checkout@v4
|
2020-05-23 19:00:02 +08:00
|
|
|
with:
|
|
|
|
ref: ${{ github.event.pull_request.head.sha }}
|
2023-12-05 20:54:06 +08:00
|
|
|
fetch-depth: 0
|
2020-05-01 17:45:30 +08:00
|
|
|
|
2023-12-05 20:54:06 +08:00
|
|
|
- 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
|
2020-07-23 16:53:37 +08:00
|
|
|
with:
|
|
|
|
repository: NeoCloud/NeoNetwork-ROA
|
|
|
|
path: generated
|
|
|
|
|
2020-07-21 01:58:59 +08:00
|
|
|
- uses: actions/setup-python@v2
|
|
|
|
with:
|
2020-07-23 16:54:34 +08:00
|
|
|
python-version: 3.x
|
|
|
|
architecture: x64
|
2020-05-01 17:45:30 +08:00
|
|
|
|
2023-12-05 19:29:55 +08:00
|
|
|
- run: pip install -r scripts/requirements.txt
|
2020-07-21 10:35:53 +08:00
|
|
|
|
2023-12-05 19:29:55 +08:00
|
|
|
- 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
|
2020-07-21 01:23:09 +08:00
|
|
|
|
2020-07-26 20:54:31 +08:00
|
|
|
- run: git -C generated diff README.md
|
2020-07-26 19:37:09 +08:00
|
|
|
|
|
|
|
- uses: actions/upload-artifact@v2
|
|
|
|
with:
|
|
|
|
name: generated
|
|
|
|
path: generated
|
2023-12-05 18:17:04 +08:00
|
|
|
|
|
|
|
comment_success:
|
|
|
|
needs: [build]
|
|
|
|
runs-on: ubuntu-20.04
|
2023-12-05 19:08:54 +08:00
|
|
|
if: ${{ always() && contains(needs.build.result, 'success') }}
|
2023-12-05 18:17:04 +08:00
|
|
|
steps:
|
2023-12-05 19:47:43 +08:00
|
|
|
- uses: actions/github-script@v7
|
2023-12-05 18:17:04 +08:00
|
|
|
with:
|
2023-12-05 19:47:43 +08:00
|
|
|
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.'
|
|
|
|
})
|
2023-12-05 18:17:04 +08:00
|
|
|
|
|
|
|
comment_failure:
|
|
|
|
needs: [build]
|
|
|
|
runs-on: ubuntu-20.04
|
2023-12-05 19:08:54 +08:00
|
|
|
if: ${{ always() && contains(needs.build.result, 'failure') }}
|
2023-12-05 18:17:04 +08:00
|
|
|
steps:
|
2023-12-05 19:08:54 +08:00
|
|
|
- shell: bash
|
|
|
|
run: |
|
2023-12-05 19:48:42 +08:00
|
|
|
echo ${{needs.build.outputs.generate_roa}} | base64 -d | tail > /tmp/buildjob_tail.log || echo 'internal error' > /tmp/buildjob_tail.log
|
2023-12-05 18:17:04 +08:00
|
|
|
|
2023-12-05 19:47:43 +08:00
|
|
|
- uses: actions/github-script@v7
|
2023-12-05 18:17:04 +08:00
|
|
|
with:
|
2023-12-05 19:47:43 +08:00
|
|
|
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,
|
2023-12-05 20:58:25 +08:00
|
|
|
body: fs.readFileSync('/tmp/buildjob_tail.log', { encoding: 'utf8', flag: 'r' })
|
2023-12-05 19:47:43 +08:00
|
|
|
})
|
2023-12-05 19:14:28 +08:00
|
|
|
|
|
|
|
- run: false
|