Skip to content

Commit

Permalink
split
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaeltm committed May 29, 2024
1 parent 5cb3c99 commit e90750d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
2 changes: 1 addition & 1 deletion samples/flask/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ This is a sample of a basic Flask TODO app. The items are stored in memory and a
### NOTE:
This sample is a simple Flask app that demonstrates how to create a TODO app using Flask. The items are stored in memory and are lost when the server is restarted. This sample is intended to provide a basic understanding of how to get started with Flask on Defang. **it is not intended for production use**. If you need something production ready, you should use a managed database like Postgres or MySQL.

TODO: Add docs?
TODO: Push sample...

## Essential Setup Files
1. A [Dockerfile](https://docs.docker.com/develop/develop-images/dockerfile_best-practices/).
Expand Down
27 changes: 22 additions & 5 deletions scripts/template-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,22 +83,39 @@ module.exports = async ({ github, context, core }) => {

const currentBranch = process.env.GITHUB_HEAD_REF.split('/').pop();
const isMain = currentBranch === 'main';
const branch = isMain ? 'main' : `test-${currentBranch}`;
const remoteBranch = isMain ? 'main' : `test-${currentBranch}`;

console.log('@@ push token exists? ', process.env.PUSH_TOKEN);

const cmd = `git subtree push --prefix samples/${sample} https://x-access-token:${process.env.PUSH_TOKEN}@github.com/DefangLabs/${templateRepo}.git ${branch}`;
const authedRemote = `https://x-access-token:${process.env.PUSH_TOKEN}@github.com/DefangLabs/${templateRepo}.git`

// add space between each char
console.log('@@ cmd: ', cmd.split('').join(' '));
const splitBranch = sample;

exec(cmd, (err, stdout, stderr) => {
exec(`git subtree split --prefix samples/${sample} -b ${splitBranch}`, (err, stdout, stderr) => {
console.log(`stdout: ${stdout}`);
console.log(`stderr: ${stderr}`);
if (err) {
throw new Error(`exec error: ${err}`);
}
});

exec(`git checkout ${splitBranch}`, (err, stdout, stderr) => {
console.log(`stdout: ${stdout}`);
console.log(`stderr: ${stderr}`);
if (err) {
throw new Error(`exec error: ${err}`);
}
});


exec(`git push ${authedRemote} ${splitBranch}:${remoteBranch} --force`, (err, stdout, stderr) => {
console.log(`stdout: ${stdout}`);
console.log(`stderr: ${stderr}`);
if (err) {
throw new Error(`exec error: ${err}`);
}
});

}

return {
Expand Down

0 comments on commit e90750d

Please sign in to comment.