This repository has been archived by the owner on Jul 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Allows using renovate.json
as file to update baseBranches
#1
Open
JordiVM
wants to merge
2
commits into
DaRaFF:master
Choose a base branch
from
JordiVM:renovate-file
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
|
@@ -28,23 +28,31 @@ const getHighestTag = async ({repo, owner, token}) => { | |
} | ||
|
||
// main application | ||
module.exports = async ({owner, repo, ghToken, ghApprovalToken, file, targetBranch}) => { | ||
module.exports = async ({owner, repo, ghToken, ghApprovalToken, file, targetBranch, release}) => { | ||
const token = ghToken | ||
|
||
if (token === ghApprovalToken) throw new Error('gh-approval-token token must be different to the gh-token') | ||
const baseTagCommit = await getHighestTag({repo, owner, token}) | ||
|
||
// get README.md | ||
const readmeBase64Obj = await gitGetContent({owner, repo, token, path: file}) | ||
console.log('readmeBase64Obj', readmeBase64Obj) | ||
const fileBase64Obj = await gitGetContent({owner, repo, token, path: file}) | ||
console.log('fileBase64Obj', fileBase64Obj) | ||
const content = Buffer.from(fileBase64Obj.content, 'base64').toString('ascii') | ||
|
||
// add an empty line to the readme to have a code diff for the upcoming pull request | ||
const readme = Buffer.from(readmeBase64Obj.content, 'base64').toString('ascii') | ||
const newLineReadme = `\n ${readme}` | ||
const newLineReadmeEncoded = Buffer.from(newLineReadme).toString('base64') | ||
let newContent | ||
if (file === "renovate.json") { | ||
// Replace baseBranches with new release branch | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you extend the comment and describe how it looks before and after? |
||
const contentJson = JSON.parse(content) | ||
contentJson.baseBranches.splice(1, 0, release) | ||
contentJson.baseBranches = contentJson.baseBranches.slice(0,4) | ||
newContent = JSON.stringify(contentJson) | ||
} else { | ||
// add an empty line to the readme to have a code diff for the upcoming pull request | ||
newContent = `\n ${content}` | ||
} | ||
const newContentEncoded = Buffer.from(newContent).toString('base64') | ||
|
||
// create new release-branch | ||
const branchName = `bump-to-next-minor-version-${Date.now()}` | ||
const branchName = `bump-to-next-minor-version-${release}` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the consequence is that you can only do 1 bump per release (which is most probably ok). |
||
console.log(`try to create branch "${branchName}"`) | ||
const branch = await gitCreateBranch({ | ||
owner, | ||
|
@@ -59,10 +67,10 @@ module.exports = async ({owner, repo, ghToken, ghApprovalToken, file, targetBran | |
owner, | ||
repo, | ||
token, | ||
path: readmeBase64Obj.path, | ||
path: fileBase64Obj.path, | ||
message: `feat(release-management): Bump minor version for release management`, | ||
content: newLineReadmeEncoded, | ||
sha: readmeBase64Obj.sha, | ||
content: newContentEncoded, | ||
sha: fileBase64Obj.sha, | ||
branch: branchName | ||
}) | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the script only supports
README.md
orrenovate.json
, so I would add the .choices param (didn't test it out)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking that you can add a new line in any file (doesn't have to be
README.md
) but we can limit the script to just work withREADME.md
orrenovate.json
. I will try with choices :)