Skip to content

Update heroes.json #3882

Update heroes.json

Update heroes.json #3882

name: remember-brave-people
on:
pull_request_target:
paths:
- "heroes.json"
jobs:
remember-brave-people:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ref: main
fetch-depth: 0
- name: Validate PR branch name
uses: actions/github-script@v5
with:
script: |
const branchName = context.payload.pull_request.head.ref;
if (!/^[\w/-]*$/.test(branchName)) {
throw new Error(`Invalid branch name: ${branchName}`);
}
- name: Checkout PR branch
run: |
git remote add ${{ github.event.pull_request.user.login }} ${{ github.event.pull_request.head.repo.html_url }}
git fetch ${{ github.event.pull_request.user.login }}
git checkout -b ${{ github.event.pull_request.user.login }}_${{ github.event.pull_request.head.ref }} ${{ github.event.pull_request.user.login }}/${{ github.event.pull_request.head.ref }}
- uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '11'
- name: Determine player username
id: determine-player-username
uses: actions/github-script@v5
with:
script: |
if (!context.payload.pull_request.head.repo.fork && context.payload.pull_request.head.ref.startsWith('gh/')) {
core.setOutput('player-github-username', context.payload.pull_request.head.ref.substring(3).split('/')[0])
} else {
core.setOutput('player-github-username', context.payload.pull_request.user.login)
}
- name: Base64 encode PR title
id: encode-pr-title
uses: actions/github-script@v5
with:
script: |
const title = context.payload.pull_request.title;
const encodedTitle = Buffer.from(title).toString('base64');
core.setOutput('encoded-title', encodedTitle);
- name: Check Problems in Code
run: >
curl --location --fail --silent --show-error -o .git/code-checker.jar https://github.com/ByteLegend/tools/releases/download/v1.0.0/code-checker.jar &&
java
-DprLocalBranch=${{ github.event.pull_request.user.login }}_${{ github.event.pull_request.head.ref }}
-DgitHubToken=${{ secrets.GITHUB_TOKEN }}
-DprRepoFullName=${{ github.event.pull_request.base.repo.full_name }}
-DprAuthor=${{ steps.determine-player-username.outputs.player-github-username }}
-DprNumber=${{ github.event.pull_request.number }}
-DprTitleEncoded=${{ steps.encode-pr-title.outputs.encoded-title }}
-DprHeadSha=${{ github.event.pull_request.head.sha }}
-DapiUrl=https://bytelegend.com
-DinternalApiSecret=${{ secrets.INTERNAL_API_SECRET }}
-jar .git/code-checker.jar
- name: Verify and generate brave people data
run: >
docker run -v $GITHUB_WORKSPACE:/workspace blindpirate/remember-brave-people
-DworkspaceDir=/workspace
-DplayerGitHubUsername=${{ steps.determine-player-username.outputs.player-github-username }}
-DprTitleEncoded=${{ steps.encode-pr-title.outputs.encoded-title }}
-DprNumber=${{ github.event.pull_request.number }}
-DaccessKeyId=${{ secrets.AWS_ACCESS_KEY_ID }}
-DaccessKeySecret=${{ secrets.AWS_ACCESS_KEY_SECRET }}
-DheadRef=${{ github.event.pull_request.user.login }}_${{ github.event.pull_request.head.ref }}
-DrepoPushUrl=https://ByteLegendBot:${{ secrets.BYTELEGENDBOT_TOKEN }}@github.com/ByteLegendQuest/remember-brave-people.git