-
-
Notifications
You must be signed in to change notification settings - Fork 9
52 lines (46 loc) · 1.65 KB
/
update_leaderboard.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
name: Update Leaderboard
on:
issues:
types: [opened, edited]
jobs:
update_leaderboard:
if: startsWith(github.event.issue.title, 'Game Result Submission')
runs-on: ubuntu-latest
permissions:
contents: write
issues: write
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Run updateLeaderboard script
id: update_leaderboard
uses: actions/github-script@v7
with:
script: |
const updateLeaderboard = require('./.github/updateLeaderboard.js');
const result = await updateLeaderboard({ github, context });
core.setOutput('success', result); // Setting the output for later steps
core.setOutput('issueBody', context.payload.issue.body); // Get the issue body
- name: Create Pull Request
if: steps.update_leaderboard.outputs.success == 'true'
id: create_pr
uses: peter-evans/[email protected]
with:
token: ${{ secrets.GH_TOKEN }}
branch: update-leaderboard
commit-message: ':sparkles: Update leaderboard'
title: 'Update Leaderboard'
body: ${{ steps.update_leaderboard.outputs.issueBody }} # Use the issue body as PR body
base: main
- name: Close Issue
if: steps.create_pr.outputs.pull_request_url != ''
uses: actions/github-script@v7
with:
script: |
const issue_number = context.payload.issue.number;
await github.issues.update({
...context.repo,
issue_number,
state: 'closed'
});