Skip to content

Instantly share code, notes, and snippets.

@JasonFreeberg
Created June 29, 2020 17:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JasonFreeberg/90d7ee9cf278e4770cc9561a1f59e867 to your computer and use it in GitHub Desktop.
Save JasonFreeberg/90d7ee9cf278e4770cc9561a1f59e867 to your computer and use it in GitHub Desktop.
Replace template strings in workflow files
// 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