-
-
Notifications
You must be signed in to change notification settings - Fork 24
81 lines (71 loc) · 2.69 KB
/
modrinth.yml
File metadata and controls
81 lines (71 loc) · 2.69 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
name: Daily Modrinth Publish
on:
schedule:
# Runs at 00:00 UTC every day
- cron: '0 0 * * *'
# Allow manual triggering from the GitHub UI
workflow_dispatch:
inputs:
force_run:
description: 'Force run even if no recent commits (ignores commit check)'
required: false
default: 'false'
type: boolean
# Trigger when a new release is created
release:
types: [created]
jobs:
check-commits-and-publish:
if: github.repository_owner == 'SamB440'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for all branches and tags
- name: Check if should run
id: check_run
run: |
# Always run for releases or forced manual runs
if [[ "${{ github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && github.event.inputs.force_run == 'true') }}" == "true" ]]; then
echo "::set-output name=should_run::true"
echo "Release or forced run - proceeding with Modrinth publish"
# For scheduled runs, check for recent commits
else
echo "=== Debug Information ==="
echo "Current time: $(date)"
echo "24 hours ago: $(date -d '24 hours ago')"
echo "Git log history:"
git log --since="24 hours ago" --pretty=format:'%h - %s (%cr)' || echo "Git log command failed"
echo "\nChecking for commits in the last 24 hours..."
COMMIT_COUNT=$(git rev-list --count --since="24 hours ago" HEAD)
echo "Found $COMMIT_COUNT commits in the last 24 hours"
if [ "$COMMIT_COUNT" -gt 0 ]; then
echo "::set-output name=should_run::true"
else
echo "No commits found in the last 24 hours"
echo "::set-output name=should_run::false"
fi
fi
- name: Set up JDK 21
if: steps.check_run.outputs.should_run == 'true'
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
- name: Setup Gradle
if: steps.check_run.outputs.should_run == 'true'
uses: gradle/actions/setup-gradle@v4
- name: Publish to Modrinth
if: steps.check_run.outputs.should_run == 'true'
run: ./gradlew modrinth
env:
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
- name: Capture build artifacts
if: steps.check_run.outputs.should_run == 'true'
uses: actions/upload-artifact@v4
with:
name: Artifacts
path: |
**/build/libs/
*/build/libs/