Skip to content

Commit

Permalink
Add Workflow for publishing PRs to the PR Maven repository (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
shartte authored May 20, 2024
1 parent 6312c1a commit 9908daf
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 2 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/check-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
- opened
- reopened
- ready_for_review
- synchronize

jobs:
get_versions:
Expand All @@ -32,5 +33,7 @@ jobs:
version: ${{ matrix.version }}
push_changed: false
publish: false


# Publishing of PRs will only work correctly if we're only building a single one
# NOTE: There is no way to get the length of an array in Github Actions Expressions
# So the heuristic is: If it contains a comma, it's a list with more than one element.
publish_prs: ${{ !contains(needs.get_versions.outputs.versions, ',') }}
11 changes: 11 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ on:
default: true
required: false
type: boolean
publish_prs:
default: false
required: false
type: boolean
secrets:
MAVEN_USER:
required: false
Expand Down Expand Up @@ -118,6 +122,13 @@ jobs:
with:
name: neoform-${{ fromJson(steps.split_version.outputs.result).version_name }}
path: build/distributions/*.zip
# This creates a "maven-publish" artifact that contains the results of a locally run publish task
# This artifact is picked up by the "publish-prs.yml" workflow for PRs and published to a temporary maven repository
- name: Publish artifacts for PR Publication
uses: neoforged/action-pr-publishing/upload@v1
if: ${{ inputs.publish_prs }}
with:
publishing-task: ":${{ fromJson(steps.split_version.outputs.result).version_name }}:publishAllPublicationsTo_githubPackages_PRsRepository -Ptype=${{ fromJson(steps.split_version.outputs.result).version_type }}"
- name: Get Java Test Versions
id: test_versions
env:
Expand Down
30 changes: 30 additions & 0 deletions .github/workflows/publish-prs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# File generated by the GradleUtils `setupGitHubActionsWorkflows` task, avoid modifying it directly
# The template can be found at https://github.com/neoforged/GradleUtils/blob/a65628b0c89dec60b357ce3f8f6bfa62934b8357/src/actionsTemplate/resources/.github/workflows/publish-prs.yml

name: Publish PRs to GitHub Packages

on:
workflow_run:
workflows: [Check PRs]
types:
- completed
issue_comment:
types:
- edited
pull_request_target:
types:
- opened

permissions:
packages: write

jobs:
publish-prs:
if: true
uses: neoforged/actions/.github/workflows/publish-prs.yml@main
with:
artifact_base_path: net/neoforged/neoform/
uploader-workflow-name: "Check PRs"
secrets:
PR_PUBLISHING_GH_APP_ID: ${{ secrets.PR_PUBLISHING_GH_APP_ID }}
PR_PUBLISHING_GH_APP_KEY: ${{ secrets.PR_PUBLISHING_GH_APP_KEY }}

0 comments on commit 9908daf

Please sign in to comment.