-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 1.0.1 Co-authored-by: Erick Massa Sprengel <[email protected]>
- Loading branch information
1 parent
bdc3580
commit c382772
Showing
7 changed files
with
112 additions
and
51 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 |
---|---|---|
@@ -1,2 +1,33 @@ | ||
# acton | ||
Aqui rodamos tudo, o que não falta é Action | ||
|
||
|
||
``` | ||
git branch -D merge-push-on | ||
git checkout -b merge-push-on origin/pull-requests-base-branch | ||
git fetch prs-to-pull-requests-base-branch | ||
for pr in prs | ||
git merge pr on merge-push-on | ||
if conflict | ||
return error | ||
git push -f origin HEAD:merge-push-on | ||
``` | ||
|
||
``` | ||
exemplo com: | ||
merge-push-on = sdx | ||
pull-requests-base-branch = master | ||
git checkout -b sdx-${timestamp} origin/master | ||
git fetch prs-to-master | ||
for pr in prs | ||
git merge pr on sdx-${timestamp} | ||
if conflict | ||
git branch -d sdx-${timestamp} | ||
return error | ||
git branch -d sdx | ||
git checkout -b sdx | ||
git branch -d sdx-${timestamp} | ||
``` |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,21 @@ | ||
const deployBranchName = 'sdx-prs-deploy' | ||
const deployBranchName = process.env.INPUT_MERGE_PUSH_ON | ||
const deployRefName = `heads/${deployBranchName}` | ||
const deployRefHead = `refs/${deployRefName}` | ||
|
||
const token = process.env.INPUT_TOKEN | ||
const sdx = process.env.INPUT_SDX_BRANCH_NAME || 'sdx' | ||
const ref = `heads/${sdx}` | ||
const target = process.env.INPUT_PULL_REQUESTS_BASE_BRANCH | ||
const ref = `heads/${target}` | ||
|
||
const repoInfo = { | ||
owner: process.env.INPUT_OWNER, | ||
repo: process.env.INPUT_REPO, | ||
} | ||
const [owner, repo] = process.env.GITHUB_REPOSITORY.split('/') | ||
|
||
const repoInfo = { owner, repo } | ||
|
||
module.exports = { | ||
deployBranchName, | ||
deployRefName, | ||
deployRefHead, | ||
repoInfo, | ||
token, | ||
target, | ||
ref, | ||
} |
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 |
---|---|---|
@@ -1,27 +1,30 @@ | ||
const { getLastCommit, createBranch, deleteBranch, getPrs, mergeBranchs } = require('./helper') | ||
const { getLastCommitSha, createAuxBranch, deleteBranch, getPrs, mergeBranchs, recreateDeployBranch } = require('./helper') | ||
|
||
async function run() { | ||
const sdxLastCommit = await getLastCommit() | ||
const baseLastCommit = await getLastCommitSha() | ||
|
||
try { | ||
await createBranch(sdxLastCommit.sha) | ||
} catch (error) { | ||
await deleteBranch() | ||
await createBranch(sdxLastCommit.sha) | ||
} | ||
const workBranchName = await createAuxBranch(baseLastCommit) | ||
|
||
const pullRequests = await getPrs() | ||
|
||
// Check if all prs can be merged together in SDX based branch | ||
|
||
let lastMergeCommitSha | ||
for (let pull of pullRequests) { | ||
try { | ||
await mergeBranchs(pull.head.ref) | ||
} catch (error) { | ||
console.error(error.response.data.message) | ||
throw new Error('Merge conflict') | ||
console.log(`Merging PR ${pull.number}`) | ||
const { data } = await mergeBranchs(pull.head.ref) | ||
|
||
console.log(`Successful merge PR ${pull.number}`); | ||
|
||
lastMergeCommitSha = data.sha | ||
} finally { | ||
await deleteBranch(workBranchName) | ||
} | ||
} | ||
console.log('Merge Success!'); | ||
|
||
await recreateDeployBranch(lastMergeCommitSha) | ||
|
||
await deleteBranch(workBranchName) | ||
} | ||
|
||
run() |