Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions create-deployment.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
'use strict';

function fetchBranchConfig(branchName) {
function fetchBranchConfig(branchName, core) {
const fs = require('fs');
const yaml = require('js-yaml');

let fileContents = fs.readFileSync('./appspec.yml', 'utf8');
try {
let fileContents = fs.readFileSync('./appspec.yml', 'utf8');
} catch (e) {
if (e.code == 'ENOENT') {
core.setFailed('🙄 appspec.yml file not found. Hint: Did you run actions/checkout?');
process.exit();
} else {
throw e;
}
}
let data = yaml.safeLoad(fileContents);

for (var prop in data.branch_config) {
Expand All @@ -24,7 +33,7 @@ function fetchBranchConfig(branchName) {
}

exports.createDeployment = async function(applicationName, fullRepositoryName, branchName, commitId, runNumber, skipSequenceCheck, core) {
const branchConfig = fetchBranchConfig(branchName);
const branchConfig = fetchBranchConfig(branchName, core);
const safeBranchName = branchName.replace(/[^a-z0-9-/]+/gi, '-').replace(/\/+/, '--');
const deploymentGroupName = branchConfig.deploymentGroupName ? branchConfig.deploymentGroupName.replace('$BRANCH', safeBranchName) : safeBranchName;
const deploymentGroupConfig = branchConfig.deploymentGroupConfig;
Expand Down
15 changes: 12 additions & 3 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,20 @@ module.exports = JSON.parse("{\"name\":\"@octokit/rest\",\"version\":\"16.43.2\"
"use strict";


function fetchBranchConfig(branchName) {
function fetchBranchConfig(branchName, core) {
const fs = __webpack_require__(5747);
const yaml = __webpack_require__(1917);

let fileContents = fs.readFileSync('./appspec.yml', 'utf8');
try {
let fileContents = fs.readFileSync('./appspec.yml', 'utf8');
} catch (e) {
if (e.code == 'ENOENT') {
core.setFailed('🙄 appspec.yml file not found. Hint: Did you run actions/checkout?');
process.exit();
} else {
throw e;
}
}
let data = yaml.safeLoad(fileContents);

for (var prop in data.branch_config) {
Expand All @@ -40,7 +49,7 @@ function fetchBranchConfig(branchName) {
}

exports.createDeployment = async function(applicationName, fullRepositoryName, branchName, commitId, runNumber, skipSequenceCheck, core) {
const branchConfig = fetchBranchConfig(branchName);
const branchConfig = fetchBranchConfig(branchName, core);
const safeBranchName = branchName.replace(/[^a-z0-9-/]+/gi, '-').replace(/\/+/, '--');
const deploymentGroupName = branchConfig.deploymentGroupName ? branchConfig.deploymentGroupName.replace('$BRANCH', safeBranchName) : safeBranchName;
const deploymentGroupConfig = branchConfig.deploymentGroupConfig;
Expand Down