workflows: add ghcp setup
This commit is contained in:
@@ -9,7 +9,7 @@ module.exports = async ([mergedArtifactURL], helpers) => {
|
|||||||
branch: 'main',
|
branch: 'main',
|
||||||
inputs: {
|
inputs: {
|
||||||
versions: JSON.stringify(require('../../versions.json')),
|
versions: JSON.stringify(require('../../versions.json')),
|
||||||
mergedArtifactURL: mergedArtifactURL,
|
mergedArtifactURL,
|
||||||
prNumber: process.env.PR_NUMBER
|
prNumber: process.env.PR_NUMBER
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,91 @@
|
|||||||
|
/**
|
||||||
|
* setupCopilot.js
|
||||||
|
*
|
||||||
|
* Reads versions from:
|
||||||
|
* - versions.json at repo root (if present), else
|
||||||
|
* - directories under mc/
|
||||||
|
*
|
||||||
|
* For each version it runs:
|
||||||
|
* ./gradlew :mc:<version>:runServer --stacktrace
|
||||||
|
*
|
||||||
|
* Uses child_process.execSync(cmd, { stdio: 'inherit' }) so logs stream to the action console.
|
||||||
|
* Errors are caught, logged, and the loop continues. At the end the script writes
|
||||||
|
* success_versions and failed_versions to $GITHUB_OUTPUT (if available) for downstream steps.
|
||||||
|
*
|
||||||
|
* To force the action to fail if any version errors, set env FAIL_ON_ERROR=true in the workflow.
|
||||||
|
*/
|
||||||
|
|
||||||
|
const cp = require('child_process')
|
||||||
|
const fs = require('fs')
|
||||||
|
const { join } = require('path')
|
||||||
|
|
||||||
|
const failOnError = process.env.FAIL_ON_ERROR === 'true'
|
||||||
|
|
||||||
|
// Save some time by skipping old versions as we are not parallelizing builds
|
||||||
|
const versions = require('../../versions.json')
|
||||||
|
const SKIP_VERSIONS = versions.slice(0, versions.indexOf('1.21.3'))
|
||||||
|
|
||||||
|
async function main () {
|
||||||
|
|
||||||
|
if (!Array.isArray(versions) || versions.length === 0) {
|
||||||
|
console.error('No versions found (no VERSION env, no versions.json, no mc/* directories).')
|
||||||
|
process.exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('Versions to build:', versions.join(', '))
|
||||||
|
|
||||||
|
process.chdir(join(__dirname, '../../'))
|
||||||
|
|
||||||
|
const successes = []
|
||||||
|
const failures = []
|
||||||
|
|
||||||
|
for (const v of versions) {
|
||||||
|
if (SKIP_VERSIONS.includes(v)) {
|
||||||
|
console.log(`Skipping old version ${v}...`)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
console.log('')
|
||||||
|
console.log('=== Building version:', v, '===')
|
||||||
|
const cmd = `./gradlew :mc:${v}:runServer --stacktrace`
|
||||||
|
try {
|
||||||
|
// stream output to the runner logs
|
||||||
|
cp.execSync(cmd, { stdio: 'inherit' })
|
||||||
|
successes.push(v)
|
||||||
|
console.log(`✅ ${v} succeeded`)
|
||||||
|
} catch (err) {
|
||||||
|
failures.push(v)
|
||||||
|
console.error(`❌ ${v} failed (continuing to next version)`)
|
||||||
|
// continue to next version
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Write outputs for downstream jobs, if GITHUB_OUTPUT available
|
||||||
|
const ghOut = process.env.GITHUB_OUTPUT
|
||||||
|
if (ghOut) {
|
||||||
|
try {
|
||||||
|
fs.appendFileSync(ghOut, `success_versions=${JSON.stringify(successes)}\n`)
|
||||||
|
fs.appendFileSync(ghOut, `failed_versions=${JSON.stringify(failures)}\n`)
|
||||||
|
} catch (e) {
|
||||||
|
console.warn('Could not write to GITHUB_OUTPUT:', e && e.message)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
console.log('GITHUB_OUTPUT not found; printing summaries to stdout instead.')
|
||||||
|
console.log('success_versions=', JSON.stringify(successes))
|
||||||
|
console.log('failed_versions=', JSON.stringify(failures))
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('')
|
||||||
|
console.log('Summary:')
|
||||||
|
console.log(' succeeded:', JSON.stringify(successes))
|
||||||
|
console.log(' failed: ', JSON.stringify(failures))
|
||||||
|
|
||||||
|
if (failOnError && failures.length > 0) {
|
||||||
|
console.error('FAIL_ON_ERROR is true and some builds failed — exiting with non-zero code.')
|
||||||
|
process.exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
// otherwise exit 0 so the workflow continues (Copilot can triage failures)
|
||||||
|
process.exit(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
main()
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
# https://docs.github.com/en/copilot/how-tos/use-copilot-agents/coding-agent/customize-the-agent-environment
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
push:
|
||||||
|
paths:
|
||||||
|
- .github/workflows/copilot-setup-steps.yml
|
||||||
|
pull_request:
|
||||||
|
paths:
|
||||||
|
- .github/workflows/copilot-setup-steps.yml
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
copilot-setup-steps:
|
||||||
|
name: Build and generate data (single-step loop via Node)
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
timeout-minutes: 20
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Validate Gradle wrapper
|
||||||
|
uses: gradle/actions/wrapper-validation@v4
|
||||||
|
|
||||||
|
- name: Set up JDK 21
|
||||||
|
uses: actions/setup-java@v4
|
||||||
|
with:
|
||||||
|
java-version: '21'
|
||||||
|
distribution: 'temurin'
|
||||||
|
|
||||||
|
- name: Setup Gradle
|
||||||
|
uses: gradle/actions/setup-gradle@v4
|
||||||
|
with:
|
||||||
|
add-job-summary-as-pr-comment: on-failure
|
||||||
|
|
||||||
|
- name: Run Copilot setup script
|
||||||
|
run: node .github/commands/setupCopilot.js
|
||||||
|
shell: bash
|
||||||
+1
-1
@@ -4,7 +4,7 @@
|
|||||||
"description": "This tool generates minecraft-data files based on a running a server on client classpath using a fabric mod. The supported versions can be read in the directory structure. Every version has its own directory.",
|
"description": "This tool generates minecraft-data files based on a running a server on client classpath using a fabric mod. The supported versions can be read in the directory structure. Every version has its own directory.",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"fix": "standard --fix",
|
"fix": "standard --fix .github tools",
|
||||||
"bump": "node tools/newVersion.js"
|
"bump": "node tools/newVersion.js"
|
||||||
},
|
},
|
||||||
"author": "",
|
"author": "",
|
||||||
|
|||||||
Reference in New Issue
Block a user