Add auto PR generation (#48)
* Remap 1.21.6 to Mojang mappings * start working on automation * update newVersion script to use manifest * update scripts * update doc * add dispatchable bump workflow * update workflow env * update workflows
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
const cp = require('child_process')
|
||||
const gh = require('gh-helpers')()
|
||||
const bump = require('../../tools/newVersion')
|
||||
const exec = (a, o) => {
|
||||
console.log('$', a)
|
||||
cp.execSync(a, { stdio: 'inherit', ...o })
|
||||
}
|
||||
|
||||
module.exports = async ([newVersion], helpers) => {
|
||||
try {
|
||||
bump(newVersion)
|
||||
// Delete any existing branch named 'bump'
|
||||
exec('git branch -D bump')
|
||||
exec('git checkout -b bump')
|
||||
exec('git add mc/' + newVersion)
|
||||
exec('git commit -m "Add version ' + newVersion + '"')
|
||||
exec('git push origin bump --force')
|
||||
const pr = await gh.createPullRequest(
|
||||
'Add version ' + newVersion,
|
||||
'This automated PR adds version ' + newVersion,
|
||||
'bump',
|
||||
'main'
|
||||
)
|
||||
console.log('Pull request created:', pr.html_url)
|
||||
} catch (error) {
|
||||
console.log('Error bumping version:', error)
|
||||
return helpers.reply('Error bumping version: ' + error.message)
|
||||
}
|
||||
}
|
||||
|
||||
if (require.main === module) {
|
||||
const args = process.argv.slice(2)
|
||||
if (args.length !== 1) {
|
||||
console.error('Usage: node bump.js <newVersion>')
|
||||
process.exit(1)
|
||||
}
|
||||
module.exports(args, { reply: console.log })
|
||||
}
|
||||
@@ -31,6 +31,8 @@ jobs:
|
||||
|
||||
versions="${versions%,*}]"
|
||||
echo "versions=$versions" >> "$GITHUB_OUTPUT"
|
||||
- name: Ensure that versions.json includes all versions
|
||||
run: node -e 'const fs = require("fs"); const versions = JSON.parse(fs.readFileSync("versions.json", "utf8")); const expectedVersions = fs.readdirSync("mc"); if (expectedVersions.length !== versions.length || !expectedVersions.every(v => versions.includes(v))) { throw new Error("versions.json does not match the expected versions in mc/ folder"); }'
|
||||
|
||||
build:
|
||||
needs: define-versions
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
name: Repo Commands
|
||||
|
||||
on:
|
||||
issue_comment: # Handle comment commands
|
||||
types: [created]
|
||||
pull_request_target: # Handle renamed PRs
|
||||
types: [edited]
|
||||
|
||||
jobs:
|
||||
comment-trigger:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check out repository
|
||||
uses: actions/checkout@v3
|
||||
- name: Run command handlers
|
||||
uses: PrismarineJS/prismarine-repo-actions@master
|
||||
with:
|
||||
# NOTE: You must specify a Personal Access Token (PAT) with repo access here. While you can use the default GITHUB_TOKEN, actions taken with it will not trigger other actions, so if you have a CI workflow, commits created by this action will not trigger it.
|
||||
token: ${{ secrets.PAT_PASSWORD }}
|
||||
@@ -0,0 +1,15 @@
|
||||
name: handle-mcdata-update
|
||||
on:
|
||||
repository_dispatch:
|
||||
types: [mc-update]
|
||||
jobs:
|
||||
update-mcdata:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: true
|
||||
- run: npm install # install gh-helpers
|
||||
- run: node .github/commands/bump.js ${{ github.event.client_payload.tag }}
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.PAT_PASSWORD }}
|
||||
Reference in New Issue
Block a user