Skip to content

Commit

Permalink
Merge pull request #104 from code-like-a-carpenter/fix-stack-names
Browse files Browse the repository at this point in the history
ci: ensure stack names are unique for each commit
  • Loading branch information
ianwremmel authored May 27, 2023
2 parents 5d31198 + 5b3278c commit c7d02ab
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
11 changes: 11 additions & 0 deletions jest.d/environments/example.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,17 @@ export default class ExampleEnvironment extends Environment {
if (env('GITHUB_SHA', '') !== '') {
suffix = `-${env('GITHUB_SHA', '').slice(0, 7)}`;
}
if (env('GITHUB_HEAD_REF', '') !== '') {
suffix = `-${env('GITHUB_HEAD_REF').replace('/', '_').substring(0, 20)}`;
} else if (env('GITHUB_REF', '') !== '') {
const branchName = env('GITHUB_REF', '')
.split('/')
.slice(2)
.join('/')
.replace(/\/|_/g, '-')
.substring(0, 20);
suffix = `-${branchName}`;
}

this.exampleName = exampleName;
this.stackName = exampleName + suffix;
Expand Down
8 changes: 8 additions & 0 deletions scripts/crr-sam
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,17 @@ for testfile in "$@"; do
example=$(echo "$testfile" | awk -F/ '{print $2}')

suffix="${GITHUB_SHA:0:7}"
if [ -n "$GITHUB_HEAD_REF" ]; then
suffix="$suffix-$(echo "$GITHUB_HEAD_REF" | sed -e 's#/|_#-#g' | head -c 20)"
elif [ -n "$GITHUB_REF" ]; then
branch_name=$(echo "$GITHUB_REF" | cut -d '/' -f 3- | sed -e 's#/|_#-#g' | head -c 20)
suffix="$suffix-$branch_name"
fi
stack_name="$example-$suffix"

echo "::notice title=Deployment Status::${action^}ing $example to $stack_name for $testfile"
STACK_NAME="$stack_name" ./scripts/sam "$action" aws "$example"
echo "::notice title=Deployment Status::${action^}ed $example to $stack_name for $testfile"

deployed="$deployed $testfile"
done
Expand Down

0 comments on commit c7d02ab

Please sign in to comment.