Created
June 29, 2020 17:19
-
-
Save JasonFreeberg/90d7ee9cf278e4770cc9561a1f59e867 to your computer and use it in GitHub Desktop.
Replace template strings in workflow files
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
// Variables from APIs or user input | |
inputs = { | |
"web-app-name": "my_cool_webapp", | |
"azure-webapp-publish-profile-name": "pubProfile120931248234", | |
"branch": "master", | |
"java-version": "1.8", | |
"slot-name": "production", | |
} | |
// Get template from GitHub | |
let file = get("https://raw.githubusercontent.com/Azure/actions-workflow-templates/master/AppService/linux/java-jar-webapp-on-azure.yml"); | |
// Iterate over the inputs obj and replace the matching strings in the file | |
for (const key in inputs) { | |
const targetString = "${"+key+"}"; | |
file.replace(tsargetString, inputs[key]) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment