Skip to content

Commit

Permalink
trying something...
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaeltm committed May 29, 2024
1 parent e90750d commit 8116be4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 30 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: Push sample...
TODO: Push sample!

## Essential Setup Files
1. A [Dockerfile](https://docs.docker.com/develop/develop-images/dockerfile_best-practices/).
Expand Down
45 changes: 16 additions & 29 deletions scripts/template-manager.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const path = require('path');
const fs = require('fs');
const { exec } = require('child_process');
const { execSync } = require('child_process');

/**
* This function returns the value of the client payload from the context.
Expand Down Expand Up @@ -85,37 +85,24 @@ module.exports = async ({ github, context, core }) => {
const isMain = currentBranch === 'main';
const remoteBranch = isMain ? 'main' : `test-${currentBranch}`;

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

const authedRemote = `https://x-access-token:${process.env.PUSH_TOKEN}@github.com/DefangLabs/${templateRepo}.git`

const splitBranch = sample;

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}`);
}
});

try {
console.log('@@ about to split subtree: ', splitBranch);
const stdout1 = execSync(`git subtree split --prefix samples/${sample} -b ${splitBranch}`);
console.log(`stdout: ${stdout1.toString()}`);

console.log('@@ about to checkout split branch: ', splitBranch);
const stdout2 = execSync(`git checkout ${splitBranch}`);
console.log(`stdout: ${stdout2.toString()}`);

console.log('@@ about to push split branch: ', splitBranch);
const stdout3 = execSync(`git push ${authedRemote} ${splitBranch}:${remoteBranch} --force`);
console.log(`stdout: ${stdout3.toString()}`);
} catch (err) {
console.error(`exec error: ${err}`);
}
}

return {
Expand Down

0 comments on commit 8116be4

Please sign in to comment.