Skip to content

Commit 9a72c50

Browse files
committed
hangar API test
1 parent eaca8ac commit 9a72c50

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

.github/workflows/hangar.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Update Hangar Page
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
update-hangar-page:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v3
15+
16+
- name: Authenticate with Hangar
17+
id: authenticate
18+
run: |
19+
RESPONSE=$(curl -s -X POST "https://hangar.papermc.io/api/v1/authenticate?apiKey=${{ secrets.HANGAR }}" -H 'accept: application/json')
20+
TOKEN=$(echo $RESPONSE | jq -r '.token')
21+
if [[ "$TOKEN" == "null" ]]; then
22+
echo "Error: Unable to fetch JWT token"
23+
exit 1
24+
fi
25+
echo "::add-mask::$TOKEN"
26+
echo "::set-output name=token::$TOKEN"
27+
28+
- name: Update Project for Hangar
29+
run: |
30+
README_CONTENT=$(cat README.md | jq -Rs .)
31+
curl -s -X PATCH "https://hangar.papermc.io/api/v1/pages/editmain/ToolStats" \
32+
-H "content-type: application/json" \
33+
-H "Authorization: HangarAuth ${{ steps.authenticate.outputs.token }}" \
34+
-d "{\"content\":$README_CONTENT}"

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
ToolStats is a Paper plugin that display various stats about tools. This plugin is inspired off of [GearStats](https://www.spigotmc.org/resources/gearstats.12960/). You can disable/enable which stats are shown on which tools via the config. Note: stats are tracked regardless of config setting. The config is to disable the lore on the item.
1313

14+
test :3
15+
1416
Here is everything it tracks:
1517
* Blocks mined (pickaxes, shovels, axes, hoes, shears)
1618
* Crops mined (hoes)

0 commit comments

Comments
 (0)