Skip to content

Commit

Permalink
Add option for publish workflow to trigger a website update
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander01998 committed Dec 8, 2024
1 parent a20d115 commit 00f92a8
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
29 changes: 28 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ on:
required: true
type: boolean
default: true
update_website:
description: "Update wimods.net post (only works if there already is one and publish_curseforge is true)"
required: false
type: boolean
default: false

jobs:
publish:
Expand Down Expand Up @@ -91,8 +96,30 @@ jobs:
if: ${{ inputs.publish_curseforge }}
run: ./gradlew publishCurseforge --stacktrace

- name: Get CurseForge file ID
id: cf_file_id
if: ${{ inputs.publish_curseforge }}
run: |
file_id=$(./gradlew getCurseforgeId | grep -o 'CURSEFORGE_FILE_ID=[0-9]*' | grep -o '[0-9]*')
echo "file_id=$file_id" >> "$GITHUB_OUTPUT"
echo "CurseForge file ID: `$file_id`" >> $GITHUB_STEP_SUMMARY
- name: Publish to Modrinth
if: ${{ inputs.publish_modrinth }}
run: ./gradlew publishModrinth --stacktrace

# TODO: Trigger website update
- name: Trigger website update
if: ${{ inputs.update_website && inputs.publish_curseforge }}
env:
GH_TOKEN: ${{ secrets.WIMODS_NET_PUBLISH_TOKEN }}
run: |
MOD_VERSION=$(grep "mod_version" gradle.properties | cut -d'=' -f2 | tr -d ' \r' | sed 's/-MC.*$//')
MC_VERSION=$(grep "minecraft_version" gradle.properties | cut -d'=' -f2 | tr -d ' \r')
FAPI_VERSION=$(grep "fabric_version" gradle.properties | cut -d'=' -f2 | tr -d ' \r')
gh workflow run add_mod_port.yml \
-R Wurst-Imperium/wimods.net \
-f mod="wi-zoom" \
-f mod_version="$MOD_VERSION" \
-f mc_version="$MC_VERSION" \
-f fapi_version="$FAPI_VERSION" \
-f file_id="${{ steps.cf_file_id.outputs.file_id }}"
11 changes: 11 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,21 @@ publishMods {
}
}

import groovy.json.JsonSlurper

tasks.register("getCurseforgeId") {
inputs.file publishCurseforge.result
doLast {
def result = new JsonSlurper().parseText(publishCurseforge.result.get().asFile.text)
println "CURSEFORGE_FILE_ID=${result.fileId}"
}
}

afterEvaluate {
tasks.publishMods.dependsOn build
tasks.publishCurseforge.dependsOn build
tasks.publishModrinth.dependsOn build
tasks.getCurseforgeId.dependsOn publishCurseforge
}

import org.kohsuke.github.GHReleaseBuilder
Expand Down

0 comments on commit 00f92a8

Please sign in to comment.