refurbish the sample application with several enhancements #79
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Create PR Preview | |
on: | |
pull_request: | |
types: [opened, synchronize, reopened] | |
jobs: | |
preview: | |
permissions: write-all | |
runs-on: ubuntu-latest | |
timeout-minutes: 15 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 20 | |
- name: Install CDK | |
run: | | |
npm install -g aws-cdk-local aws-cdk | |
cdklocal --version | |
- name: Deploy Preview | |
uses: LocalStack/setup-localstack@endpoint_s3_ephemeral | |
env: | |
LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }} | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
state-backend: ephemeral | |
state-action: start | |
include-preview: 'true' | |
install-awslocal: 'true' | |
# Multi line commands are folding for some reason, so we enforce new lines | |
# For more predictable usage, use script files | |
preview-cmd: | | |
npm i -g yarn; | |
export NODE_OPTIONS='--tls-min-v1.2 --tls-max-v1.2 --tls-cipher-list="DEFAULT@SECLEVEL=1"' | |
yarn install; | |
yarn build:backend; | |
yarn cdklocal bootstrap; | |
yarn cdklocal deploy; | |
yarn prepare:frontend-local; | |
yarn build:frontend; | |
yarn cdklocal bootstrap --app="node dist/aws-sdk-js-notes-app-frontend.js"; | |
yarn cdklocal deploy --app="node dist/aws-sdk-js-notes-app-frontend.js"; | |
distributionId=$(awslocal cloudfront list-distributions | jq -r '.DistributionList.Items[0].Id'); | |
echo LS_PREVIEW_URL=$AWS_ENDPOINT_URL/cloudfront/$distributionId/ >> $GITHUB_ENV; |