Add workflow to send artifacts back to minecraft-data (#51)
* add a send script * update * fix marker
This commit is contained in:
@@ -6,6 +6,19 @@ const exec = (a, o) => {
|
|||||||
cp.execSync(a, { stdio: 'inherit', ...o })
|
cp.execSync(a, { stdio: 'inherit', ...o })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const generateBody = (newVersion, issueNo, prNo) => `
|
||||||
|
This automated PR sets up the relevant boilerplate for Minecraft version ${newVersion}.
|
||||||
|
|
||||||
|
Links:
|
||||||
|
- Issue: ${issueNo ? `https://github.com/PrismarineJS/minecraft-data/issues/${issueNo}` : 'N/A'}
|
||||||
|
- PR: ${prNo ? `https://github.com/PrismarineJS/minecraft-data/pull/${prNo}` : 'N/A'}
|
||||||
|
|
||||||
|
If the PR is passing, it will automatically send the generated artifacts to PrismarineJS/minecraft-data${prNo ? `#${prNo}` : ''}.
|
||||||
|
|
||||||
|
If the PR is **not** passing:
|
||||||
|
* You can help contribute to this PR by opening a PR against this <code>bump</code> branch instead of <code>main</code>.
|
||||||
|
`
|
||||||
|
|
||||||
module.exports = async ([newVersion], helpers) => {
|
module.exports = async ([newVersion], helpers) => {
|
||||||
try {
|
try {
|
||||||
bump(newVersion)
|
bump(newVersion)
|
||||||
@@ -17,8 +30,8 @@ module.exports = async ([newVersion], helpers) => {
|
|||||||
exec('git commit -m "Add version ' + newVersion + '"')
|
exec('git commit -m "Add version ' + newVersion + '"')
|
||||||
exec('git push origin bump --force')
|
exec('git push origin bump --force')
|
||||||
const pr = await gh.createPullRequest(
|
const pr = await gh.createPullRequest(
|
||||||
'Add version ' + newVersion,
|
'🎈 Add version ' + newVersion, // special marker
|
||||||
'This automated PR adds version ' + newVersion,
|
generateBody(newVersion, process.env.MCDATA_ISSUE_NO, process.env.MCDATA_PULL_NO),
|
||||||
'bump',
|
'bump',
|
||||||
'main'
|
'main'
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
const gh = require('gh-helpers')()
|
||||||
|
|
||||||
|
module.exports = async ([mergedArtifactURL], helpers) => {
|
||||||
|
// Have minecraft-data handle this successful update
|
||||||
|
const dispatchPayload = {
|
||||||
|
owner: 'PrismarineJS',
|
||||||
|
repo: 'minecraft-data',
|
||||||
|
workflow: 'handle-mcpc-generator.yml',
|
||||||
|
branch: 'main',
|
||||||
|
inputs: {
|
||||||
|
versions: JSON.stringify(require('../../versions.json')),
|
||||||
|
mergedArtifactURL: mergedArtifactURL,
|
||||||
|
prNumber: process.env.PR_NUMBER
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.log('Sending workflow dispatch', dispatchPayload)
|
||||||
|
await gh.sendWorkflowDispatch(dispatchPayload)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (require.main === module) {
|
||||||
|
const merged = process.env.ARTIFACT_URL
|
||||||
|
console.log('Handling merged artifacts @', merged)
|
||||||
|
module.exports([merged], { reply: console.log })
|
||||||
|
}
|
||||||
@@ -10,6 +10,9 @@ on:
|
|||||||
permissions:
|
permissions:
|
||||||
pull-requests: write
|
pull-requests: write
|
||||||
|
|
||||||
|
env:
|
||||||
|
MARKER: '🎈'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
define-versions:
|
define-versions:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@@ -92,8 +95,19 @@ jobs:
|
|||||||
merge-multiple: true
|
merge-multiple: true
|
||||||
|
|
||||||
- name: Upload artifact
|
- name: Upload artifact
|
||||||
|
id: uploadMerged
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: merged-data
|
name: merged-data
|
||||||
path: artifacts/*
|
path: artifacts/*
|
||||||
if-no-files-found: error
|
if-no-files-found: error
|
||||||
|
|
||||||
|
- name: Sending artifacts to minecraft-data
|
||||||
|
# Check if PR starts with marker
|
||||||
|
if: startsWith(github.event.pull_request.title, env.MARKER)
|
||||||
|
env:
|
||||||
|
ARTIFACT_URL: ${{ steps.uploadMerged.outputs.artifact-url }}
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
PR_TITLE: ${{ github.event.pull_request.title }}
|
||||||
|
PR_NUMBER: ${{ github.event.pull_request.number }}
|
||||||
|
run: node .github/commands/send.js
|
||||||
|
|||||||
@@ -6,6 +6,13 @@ on:
|
|||||||
description: 'What new version is like `1.21.6`'
|
description: 'What new version is like `1.21.6`'
|
||||||
required: true
|
required: true
|
||||||
default: '1.21.6'
|
default: '1.21.6'
|
||||||
|
pr_number:
|
||||||
|
description: 'What is the relevant minecraft-data PR URL?'
|
||||||
|
required: false
|
||||||
|
issue_number:
|
||||||
|
description: 'What is the relevant minecraft-data issue?'
|
||||||
|
required: false
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
update-mcdata:
|
update-mcdata:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@@ -16,4 +23,7 @@ jobs:
|
|||||||
- run: npm install # install gh-helpers
|
- run: npm install # install gh-helpers
|
||||||
- run: node .github/commands/bump.js ${{ github.event.inputs.version }}
|
- run: node .github/commands/bump.js ${{ github.event.inputs.version }}
|
||||||
env:
|
env:
|
||||||
|
MC_VERSION: ${{ github.event.inputs.version }}
|
||||||
|
MCDATA_PULL_NO: ${{ github.event.inputs.pr_number }}
|
||||||
|
MCDATA_ISSUE_NO: ${{ github.event.inputs.issue_number }}
|
||||||
GITHUB_TOKEN: ${{ secrets.PAT_PASSWORD }}
|
GITHUB_TOKEN: ${{ secrets.PAT_PASSWORD }}
|
||||||
|
|||||||
Reference in New Issue
Block a user