Skip to content

Commit

Permalink
n
Browse files Browse the repository at this point in the history
  • Loading branch information
USA-RedDragon committed Jul 2, 2024
1 parent 606c423 commit aa346e2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 46 deletions.
4 changes: 0 additions & 4 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ inputs:
description: List/CSV of jobs to deploy per environment.
required: false
default: app
debug:
description: Adds debug logging to the output
required: false
default: "false"
outputs:
matrix:
description: Matrix JSON to be used in another job.
Expand Down
25 changes: 4 additions & 21 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 4 additions & 21 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,10 @@ import {
try {
const envs = yaml.load(core.getInput("envs"));
const jobs = parseDynamicList(core.getInput("jobs"));
const debug = core.getInput("debug") === "true";
const matrix = { include: [] };

// Split GitHub ref into type (heads, tags) and ref
const [, type, ref] = github.context.ref.match(/^refs\/(.+)\/(.+)$/);
if (debug) {
core.info(`Type: "${type}"`);
core.info(`Ref: "${ref}"`);
core.info(`Event: "${github.context.eventName}"`);
core.info(`Event action: "${github.context.payload.action}"`);
}

let count = 0;
for (let [env, value] of Object.entries(envs)) {
Expand All @@ -35,36 +28,28 @@ try {
patterns = value;
} else {
if (value.type === "temp") {
if (debug) core.info(`Temporary Environment`);
// Temp environments enabled
if (github.context.eventName === "pull_request") {
const prEvent = github.context.payload;
let matches = false;
if (prEvent.action !== "closed") {
if (value.label) {
if (debug)
core.info(`Pull Request Event: Labelled: ${value.label}`);
matches = prEvent.pull_request.labels.some(
(label) => label.name === value.label,
);
} else if (value.removed_label) {
if (debug)
core.info(
`Pull Request Event: Unlabelled: ${value.removed_label}`,
);
matches = !prEvent.pull_request.labels.some(
(label) => label.name === value.removed_label,
);
}
} else {
if (debug) core.info("Closed PR event");
if (debug) core.info(yaml.dump(prEvent.pull_request.labels));
matches = !prEvent.pull_request.labels.some(
// Closed PR, check if the removed label is on it
matches = prEvent.pull_request.labels.some(
(label) => label.name === value.removed_label,
);
}
if (matches) {
if (debug) core.info(`Labels match: ${value.label}`);
core.info(`Labels match: ${value.label}`);
patterns = ref;
value.name = `${value.name || toTitleCase(env)} #${prEvent.number}`;
env += prEvent.number;
Expand All @@ -83,9 +68,7 @@ try {
}
}

if (debug) {
core.info(`Patterns: "${patterns}"`);
}
core.info(`Patterns: "${patterns}"`);

extraValues = { ...value };
delete extraValues.branch;
Expand Down

0 comments on commit aa346e2

Please sign in to comment.