-
Notifications
You must be signed in to change notification settings - Fork 0
67 lines (55 loc) · 2.03 KB
/
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
name: Hacktoberfest Leaderboard
on:
pull_request:
types: [closed]
jobs:
update-leaderboard:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Check if the PR was merged
if: github.event.pull_request.merged == true
run: echo "PR merged"
- name: Set contributor points
id: set_points
run: |
POINTS=0
if [[ $(echo "${{ github.event.pull_request.labels }}" | grep -q "small") ]]; then
POINTS=5
elif [[ $(echo "${{ github.event.pull_request.labels }}" | grep -q "medium") ]]; then
POINTS=10
elif [[ $(echo "${{ github.event.pull_request.labels }}" | grep -q "large") ]]; then
POINTS=15
fi
echo "::set-output name=points::$POINTS"
- name: Get current leaderboard
uses: actions/github-script@v6
id: leaderboard
with:
script: |
const issue_number = 1; # Replace with your leaderboard issue number
const repo_owner = 'galaxy-bytes'; # Replace with your org or repo owner
const repo_name = 'main-test-repo'; # Replace with the repo containing the leaderboard issue
const { data: issue } = await github.issues.get({
owner: repo_owner,
repo: repo_name,
issue_number: issue_number
});
return issue.body;
- name: Update leaderboard
uses: actions/github-script@v6
with:
script: |
const contributor = github.actor;
const new_points = ${{ steps.set_points.outputs.points }};
const leaderboard = ${{ steps.leaderboard.outputs.result }};
let updated_leaderboard = updateLeaderboard(contributor, new_points, leaderboard);
await github.issues.update({
owner: 'your-org',
repo: 'Repo-A',
issue_number: 123, # Replace with the actual issue number
body: updated_leaderboard
});
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}