Skip to content

Commit

Permalink
Fix PR workflow caching and upload build artifacts (#696)
Browse files Browse the repository at this point in the history
  • Loading branch information
object-Object authored Aug 21, 2024
2 parents 5bb1ed1 + ca02f95 commit bfeb520
Showing 1 changed file with 46 additions and 9 deletions.
55 changes: 46 additions & 9 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ name: Build pull request
on:
pull_request:
workflow_dispatch:
# trigger on pushes to the default branch (main) to keep the cache up to date
push:
branches: main

env:
JAVA_VERSION: '17.0.1'

jobs:
build:
Expand All @@ -17,26 +23,57 @@ jobs:
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: "17.0.1"
java-version: ${{ env.JAVA_VERSION }}
- uses: gradle/actions/setup-gradle@v3
- name: Clean

- name: Build
run: |
chmod +x gradlew
./gradlew clean
./gradlew build
- name: Build
run: ./gradlew build
- name: Prepare artifacts for upload
run: |
mkdir -p dist
cp {Common,Forge,Fabric}/build/libs/*.jar dist
- name: Run Datagen
run: ./gradlew runAllDatagen
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: mod-build
path: dist
retention-days: 30

datagen:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: ${{ env.JAVA_VERSION }}
- uses: gradle/actions/setup-gradle@v3

# ForgeGradle datagen asset download often fails (see #692)
# so just allow it to automatically retry a few times
- name: Run datagen
uses: nick-fields/retry@v3
with:
timeout_minutes: 10
max_attempts: 3
command: |
chmod +x gradlew
./gradlew runAllDatagen
- name: Check Datagen
- name: Check datagen
run: |
git add --intent-to-add .
git diff --name-only --exit-code -- ":!:*/src/generated/resources/.cache/*"
hexdoc:
# don't bother running the docs build when pushing to main - nothing necessary to cache here
if: github.event_name != 'push'
uses: hexdoc-dev/hexdoc/.github/workflows/hexdoc.yml@main
permissions:
contents: write
Expand Down

0 comments on commit bfeb520

Please sign in to comment.