Created
March 25, 2024 07:50
-
-
Save uurtech/769cbfcc9f24f2e229cbe531abd8a6d9 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
const { spawn } = require('child_process'); | |
module.exports.slackCommandHandler = async (event) => { | |
const { text } = event.body; | |
const deployWorkflow = spawn('curl', [ | |
'-X', 'POST', | |
'-H', 'Authorization: token YOUR_GITHUB_TOKEN', | |
'-H', 'Accept: application/vnd.github.v3+json', | |
'https://api.github.com/repos/your_username/your_repo/actions/workflows/your_workflow_dispatch.yml/dispatches', | |
'-d', `{"ref":"${text}"}`, | |
]); | |
deployWorkflow.stdout.on('data', (data) => { | |
console.log(`stdout: ${data}`); | |
}); | |
deployWorkflow.stderr.on('data', (data) => { | |
console.error(`stderr: ${data}`); | |
}); | |
deployWorkflow.on('close', (code) => { | |
console.log(`child process exited with code ${code}`); | |
}); | |
return { | |
statusCode: 200, | |
body: JSON.stringify({ | |
message: `Deployment process has started for branch: ${text}`, | |
}), | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment