diff --git a/.github/workflows/hangar.yml b/.github/workflows/hangar.yml new file mode 100644 index 0000000..a82e7ef --- /dev/null +++ b/.github/workflows/hangar.yml @@ -0,0 +1,31 @@ +name: Update Hangar Description +on: + push: + branches: [ master ] +jobs: + update-hangar-page: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Authenticate with Hangar + id: authenticate + run: | + RESPONSE=$(curl -s -X POST "https://hangar.papermc.io/api/v1/authenticate?apiKey=${{ secrets.HANGAR }}" -H 'accept: application/json') + TOKEN=$(echo $RESPONSE | jq -r '.token') + if [[ "$TOKEN" == "null" ]]; then + echo "Error: Unable to fetch JWT token" + exit 1 + fi + echo "::add-mask::$TOKEN" + echo "token=$TOKEN" >> $GITHUB_OUTPUT + + - name: Update Project Description + run: | + README_CONTENT=$(cat README.md | jq -Rs .) + curl -s -X PATCH "https://hangar.papermc.io/api/v1/pages/editmain/AnarchyStats" \ + -H "content-type: application/json" \ + -H "Authorization: HangarAuth ${{ steps.authenticate.outputs.token }}" \ + -d "{\"content\":$README_CONTENT}" \ No newline at end of file diff --git a/.github/workflows/modrinth.yml b/.github/workflows/modrinth.yml index af07810..9d704a0 100644 --- a/.github/workflows/modrinth.yml +++ b/.github/workflows/modrinth.yml @@ -1,3 +1,4 @@ +name: Update Modrinth Description on: push: branches: [ master ]