-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sync agent-helm release with the agent one SCALRCORE-27249
- Loading branch information
Showing
7 changed files
with
163 additions
and
122 deletions.
There are no files selected for viewing
14 changes: 5 additions & 9 deletions
14
...ub/actions/update-app-version/action.yaml → .github/actions/sync-app-version/action.yaml
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
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,56 @@ | ||
const yaml = require('js-yaml'); | ||
const core = require('@actions/core'); | ||
const semver = require('semver'); | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
const chartsDir = path.join(process.env.GITHUB_WORKSPACE, 'charts'); | ||
const appVersion = core.getInput('app_version', { required: true }); | ||
const upstream = core.getInput('upstream', { required: true }); | ||
|
||
function getCharts() { | ||
const files = fs.readdirSync(chartsDir); | ||
const directories = files.filter((file) => { | ||
const filePath = path.join(chartsDir, file); | ||
return fs.statSync(filePath).isDirectory(); | ||
}); | ||
core.debug(`Charts: ${directories}`); | ||
return directories; | ||
} | ||
|
||
function update_charts() { | ||
const charts = getCharts() | ||
core.info(`The appVersion ${appVersion}`); | ||
charts.forEach(function (chart) { | ||
chartPath = path.join(chartsDir, chart, "Chart.yaml") | ||
const chartData = yaml.load(fs.readFileSync(chartPath, 'utf8')) | ||
|
||
chartData.appVersion = appVersion; | ||
chartData.version = semver.inc(chartData.version, 'patch'); | ||
const updatedYaml = yaml.dump(chartData); | ||
fs.writeFileSync(chartPath, updatedYaml, 'utf8'); | ||
core.info(`The new version of ${chart} is ${chartData.version}`); | ||
}); | ||
|
||
} | ||
async function push_changes() { | ||
await exec.exec('git config user.name "github-actions[bot]"'); | ||
await exec.exec('git config user.email "github-actions[bot]@users.noreply.github.com"'); | ||
await exec.exec(`git checkout -b ${process.env.PR_BRANCH}`); | ||
await exec.exec('git add charts'); | ||
await exec.exec(`git commit -m "Sync appVersion: ${appVersion}. Triggered by ${upstream}"`); | ||
await exec.exec(`git push origin ${process.env.PR_BRANCH} --force`); | ||
} | ||
|
||
async function run() { | ||
try { | ||
update_charts() | ||
push_changes() | ||
// draft_pr() | ||
} catch (err) { | ||
return core.setFailed(`Error: ${err}`) | ||
} | ||
|
||
} | ||
|
||
run(); |
File renamed without changes.
4 changes: 2 additions & 2 deletions
4
...b/actions/update-app-version/package.json → ...hub/actions/sync-app-version/package.json
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