-
Notifications
You must be signed in to change notification settings - Fork 342
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
2,989 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: 'Modify package json' | ||
description: 'Modify package json' | ||
inputs: | ||
defaultChannel: | ||
description: 'The Default Channel' | ||
required: false | ||
channel: | ||
description: 'The channel will be edited' | ||
required: false | ||
version: | ||
description: 'Version' | ||
required: true | ||
srcPath: | ||
description: 'package.json path' | ||
required: true | ||
destPath: | ||
description: 'Output path' | ||
required: true | ||
outputs: | ||
outputPath: | ||
description: 'Output absolute path' | ||
runs: | ||
using: 'node16' | ||
main: 'index.js' |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
const core = require('@actions/core'); | ||
const path = require('path'); | ||
const fs = require('fs'); | ||
|
||
try { | ||
const defaultChannel = core.getInput('defaultChannel'); | ||
let channel = core.getInput('channel'); | ||
const version = core.getInput('version'); | ||
const srcPath = core.getInput('srcPath'); | ||
const destPath = core.getInput('destPath'); | ||
|
||
const workdir = process.env.GITHUB_WORKSPACE; | ||
const src = path.resolve(workdir, srcPath); | ||
const content = fs.readFileSync(src, 'utf8').toString(); | ||
|
||
console.log(`read content: ${content}`); | ||
|
||
const packageJson = JSON.parse(content); | ||
|
||
if (defaultChannel) { | ||
packageJson.defaultChannel = defaultChannel; | ||
} | ||
|
||
if (!channel) { | ||
channel = packageJson.defaultChannel; | ||
} | ||
|
||
packageJson.channels[channel].push(version); | ||
|
||
const dest = path.resolve(workdir, destPath); | ||
const newContent = JSON.stringify(packageJson, null, 2) | ||
fs.writeFileSync(dest, newContent); | ||
|
||
console.log(`write content to ${dest}`); | ||
console.log(`new content: ${newContent}`) | ||
|
||
core.setOutput("outputPath", dest); | ||
|
||
} catch (e) { | ||
core.setFailed(e.message); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters