An action for publishing PRs to a GitHub Packages.
The action is split into two steps:
This step can be part of a pull_request
workflow, as it does not need secrets.
The actions in this step:
- Prepare a Gradle init script that adds a new,
_githubPackages_PRs
repository to all projects that have themaven-publish
plugin applied, and that points to a local directory; - Run the
publishAllPublicationsTo_githubPackages_PRsRepository
Gradle task; - Pack the workflow event payload alongside the local maven directory into a workflow artifact named
maven-publish
.
This step must be run with a workflow_run
dispatch listening for the workflow that runs the first step.
Additionally, this step requires the following permissions:
permissions:
packages: write # To upload the PR
actions: write # To get information about the uploading workflow run and to delete the run artifacts
contents: write # To download the `maven-publish` artifact, and to be able to create commit comments
issues: write # To be able to create PR comments
pull-requests: write # To be able to create PR comments
The actions in this step:
- Process information about the uploading workflow run. If not successful, abort;
- Download the
maven-publish
artifact that was uploaded by the uploading workflow; - Upload the (filtered) contents of the artifact to a GitHub sub-package of the repository, that has the
pr<number>.
prefix; delete the workflow artifact so that in the future re-publishing is not attempted; - OPTIONAL STEP, only if the repository's name is
NeoForge
: generate an MDK pointing to the published version of the PR (more information on mdk generation below); - Comment on the PR with information on the published artifacts (and an MDK link and installer link if necessary), or update an existing comment;
- Comment on the commit with the same message as above.
If the name of the repository this action runs on is NeoForge
(case insensitive), the action will generate an MDK.
The branch of the MDK being used as base will be decided based on the Minecraft component of the artifact version (i.e. the 20.2
in 20.2-beta-pr1
). The expected branch name is 1.<component>
(i.e. 1.20.2
).
If such branch is not found, the action will use the main
branch as the base.
Replacements:
- A line starting with exactly
neo_version=
in thegradle.properties
file will be updated with the published artifact version; - A line starting with exactly
minecraft_version=
in thegradle.properties
file will be updated with the correct Minecraft version (relevant if the base branch ismain
); - The PR repository declaration block will be added before a
dependencies {
line.