Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

initial commit in fresh branch #2150

Draft
wants to merge 17 commits into
base: main
Choose a base branch
from
Draft
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
28 changes: 28 additions & 0 deletions .github/actions/update-cfn-templates/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: 'Update CFN Templates'
description: 'Fetch cached CFN templates if unchanged, or generate updates ones'
inputs:
custom-cdk-dir:
description: 'Custom CDK directory'
required: false
default: './cdk'
runs:
using: 'composite'
steps:
- name: 'Checkout'
uses: actions/checkout@v4
with:
fetch-depth: 2

- name: 'Check for changes'
run: ./script/diff_cdk_dir.sh ${{ inputs.custom-cdk-dir }} ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }}
shell: bash

- name: 'Build new CFN templates'
if: ${{ env.CDK_CHANGES == 'true' }}
run: ./script/cfn.sh ${{ inputs.custom-cdk-dir }}
shell: bash

- name: 'Fetch cached CFN templates'
if: ${{ env.CDK_CHANGES == 'false' }}
run: echo "There are no CDK changes from main"
shell: bash
19 changes: 19 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Test
on:
pull_request:
workflow_dispatch:
push:
branches:
- main
jobs:
test-job:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Use local action
uses: './.github/actions/update-cfn-templates'
1 change: 1 addition & 0 deletions cdk/bin/cdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,4 @@ new DiscountApi(app, 'discount-api-PROD', {
hostedZoneId: supportHostedZoneId,
certificateId: supportCertificateId,
});

3 changes: 2 additions & 1 deletion script/cfn.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
set -e
set -x

CDK_DIR=$1
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
ROOT_DIR="${DIR}/.."
cd "$ROOT_DIR/cdk"
cd "$ROOT_DIR/$CDK_DIR"

yarn install --frozen-lockfile
yarn tsc
Expand Down
12 changes: 12 additions & 0 deletions script/diff_cdk_dir.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

CDK_DIR=$1
BASE=$2
HEAD=$3

git diff --quiet $BASE..$HEAD $CDK_DIR
if [ $? -eq 0 ]; then
echo "CDK_CHANGES=false" >> $GITHUB_ENV
else
echo "CDK_CHANGES=true" >> $GITHUB_ENV
fi
Loading