Skip to content

Commit

Permalink
update release-apps
Browse files Browse the repository at this point in the history
  • Loading branch information
pierregee committed Nov 9, 2023
1 parent d7d5907 commit 52a5e7e
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions .github/scripts/release-ecr-tags.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/**
* Release Tags
*
* Creating release tag based on each release version for AWS ECR Public
*
*/

module.exports = ({ context }) => {
if (context.eventName === "release") {
return getReleaseTag(context);
}
if (isStaging(context) === true) {
return getMainTag(context);
}
if (isDev(context) === true) {
return getPullRequestTag(context);
}
throw new Error(
"Release Violation: Could not determine the required release tags."
);
};

function getReleaseTag(context) {
const semver = context.payload.release.tag_name;
if (semver.match(/^v[0-9]+\.[0-9]+\.[0-9]+$/) === null) {
throw new Error(
`Release Violation: Provided version '${semver}' is not valid semver.`
);
}
return semver.replace("v", "");
}

function getMainTag({ sha }) {
return `${sha}`;
}

function getPullRequestTag({ payload: { number }, sha }) {
return `pr-${number}`;
}

function isStaging(context) {
return context.eventName === "push" && context.ref === "refs/heads/main";
}

function isDev(context) {
return context.eventName === "pull_request";
}

0 comments on commit 52a5e7e

Please sign in to comment.