A github action that provides a preview of changed minecraft models in a pull request.
  • TypeScript 99.8%
  • JavaScript 0.2%
Find a file
Smell of curry e0b349b1d6
All checks were successful
CI / test (push) Successful in 42s
CI / lint (push) Successful in 24s
Render subpack assets with correct box UVs (#3)
2026-12-03 20:28:42 +00:00
.cursor/rules Fix: Patch Interface.tab_bar.new_tab in Blockbench bundle 2026-01-28 12:00:21 -05:00
.github/workflows Deliver Forgejo model previews as native artifacts 2026-11-27 01:10:59 +00:00
dist Render subpack assets with correct box UVs (#3) 2026-12-03 20:28:42 +00:00
src Render subpack assets with correct box UVs (#3) 2026-12-03 20:28:42 +00:00
.gitignore cleanup 2026-01-28 13:36:55 -05:00
action.yml Deliver Forgejo model previews as native artifacts 2026-11-27 01:10:59 +00:00
jest.config.js cleanup 2026-01-28 13:36:55 -05:00
package-lock.json Refresh compatible Model Preview dependencies (#1) 2026-11-27 00:07:25 +00:00
package.json Add fork PR support with workflow_run artifact flow 2026-01-28 17:06:31 -05:00
README.md Deliver Forgejo model previews as native artifacts 2026-11-27 01:10:59 +00:00
tsconfig.json init 2025-08-21 17:19:34 -04:00

Minecraft Model Preview

A GitHub Action that automatically generates visual previews of changed Minecraft Bedrock Edition models in pull requests.

Features

  • Detects new or modified entity models, textures, and animations in PRs
  • Generates side-by-side "before" and "after" renders
  • Supports shiny texture variants (for Pokemon-style resource packs)
  • Posts comparison images directly as PR comments
  • Falls back to job summary if PR comments aren't available

Usage

Add this workflow to your repository at .github/workflows/model-preview.yml:

name: Model Preview

on:
  pull_request:

permissions:
  contents: write
  pull-requests: write

jobs:
  model-preview:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0 # Required for base branch comparison

      - name: Minecraft Model Preview
        uses: smell-of-curry/mc-model-preview@latest
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}

Inputs

Input Description Required Default
github-token GitHub.com token for API access and PR comments GitHub.com only -
resource-pack-path Path to the resource pack in your repository No .
mode Action mode: render (default) or post No render
artifact-path Path to downloaded artifact directory (required for post mode) No -

Forgejo previews

On Forgejo, the action compares the checked-out PR commits locally and stages the rendered PNG and GIF files for native workflow artifact upload. Checkout must fetch the PR commits and their history. The preview does not need a GitHub token.

Give the preview step an id of preview and pass its preview-artifact-path and preview-artifact-name outputs to Forgejo's upload-artifact action. Skip the upload when the path is empty. Reviewers can download the preview from the Forgejo Actions run. Each run renders the current PR diff.

Custom Resource Pack Path

If your resource pack is in a subdirectory:

- name: Minecraft Model Preview
  uses: smell-of-curry/mc-model-preview@latest
  with:
    github-token: ${{ secrets.GITHUB_TOKEN }}
    resource-pack-path: './my-resource-pack'

Fork PR Support

Pull requests from forks have limited permissions and cannot push images to branches or post comments directly. This action automatically detects fork PRs and uploads rendered images as workflow artifacts instead.

To enable full fork PR support with automatic comment posting, you need two workflows:

1. Main Workflow (.github/workflows/model-preview.yml)

This workflow runs on pull requests and renders the models. For fork PRs, it saves images as an artifact.

name: Model Preview

on:
  pull_request:

permissions:
  contents: write
  pull-requests: write

jobs:
  model-preview:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - name: Minecraft Model Preview
        uses: smell-of-curry/mc-model-preview@latest
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}

2. Post Workflow (.github/workflows/model-preview-post.yml)

This workflow runs after the main workflow completes, downloads the artifact, and posts the comment with full permissions.

name: Post Model Preview

on:
  workflow_run:
    workflows: ["Model Preview"]
    types: [completed]

permissions:
  contents: write
  pull-requests: write

jobs:
  post-comment:
    runs-on: ubuntu-latest
    if: >
      github.event.workflow_run.conclusion == 'success' &&
      github.event.workflow_run.event == 'pull_request'

    steps:
      - uses: actions/checkout@v4

      - name: Get PR number
        id: pr
        uses: actions/github-script@v7
        with:
          script: |
            const artifacts = await github.rest.actions.listWorkflowRunArtifacts({
              owner: context.repo.owner,
              repo: context.repo.repo,
              run_id: context.payload.workflow_run.id,
            });
            const artifact = artifacts.data.artifacts.find(a => a.name.startsWith('model-preview-pr-'));
            if (!artifact) {
              core.info('No model preview artifact found');
              return;
            }
            const prNumber = artifact.name.replace('model-preview-pr-', '');
            core.setOutput('number', prNumber);
            core.setOutput('artifact_name', artifact.name);

      - name: Download artifact
        if: steps.pr.outputs.number
        uses: actions/download-artifact@v4
        with:
          name: ${{ steps.pr.outputs.artifact_name }}
          path: artifact
          run-id: ${{ github.event.workflow_run.id }}
          github-token: ${{ secrets.GITHUB_TOKEN }}

      - name: Post Model Preview Comment
        if: steps.pr.outputs.number
        uses: smell-of-curry/mc-model-preview@latest
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}
          mode: post
          artifact-path: artifact

Note: For non-fork PRs, the main workflow handles everything automatically—no second workflow is needed. The post workflow only activates when an artifact is present (fork PRs).

How It Works

  1. Scans Entity Files: Parses all entity/*.json files to build a map of entity identifiers to their associated resources (models, textures, animations, materials)

  2. Detects Changes: Compares the PR's changed files against the entity resource map to identify affected entities

  3. Generates Renders: For each affected entity:

    • Creates a .bbmodel (BlockBench) representation
    • Renders the model using Three.js in a headless browser
    • Captures both "before" (base branch) and "after" (PR branch) states
  4. Posts Results: Uploads rendered images and posts a comparison table to the PR

Resource Pack Structure

The action expects a standard Minecraft Bedrock resource pack structure:

your-resource-pack/
├── entity/           # Entity definition files (.json)
├── models/           # Geometry files (.json)
│   └── entity/
├── textures/         # Texture files (.png, .tga)
│   └── entity/
├── animations/       # Animation files (.json)
└── materials/        # Material files (.material, .json)

Example Output

When a PR modifies entity models or textures, the action posts a comment like:

Entity Before After
minecraft:creeper before after
pokeb:pikachu New model after
pokeb:pikachu (shiny) New model after

Requirements

  • The workflow must have contents: write and pull-requests: write permissions
  • Use fetch-depth: 0 in checkout to enable base branch comparison
  • Runs on ubuntu-latest (requires Chrome for headless rendering)

License

ISC