Skip to content

Add deploy of demo iframe app for /api/ testing #836

Add deploy of demo iframe app for /api/ testing

Add deploy of demo iframe app for /api/ testing #836

Workflow file for this run

# Workflow references:
# https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions
# https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: CI
on:
push:
branches: [main]
paths:
- '**'
- '!**/README.md'
pull_request:
branches: [main]
paths:
- '**'
- '!**/README.md'
env:
# This is used by the SharedProps to detect a PR build
PR_NUMBER: ${{ github.event.pull_request.number }}
# Set env to prod so we don't get an env suffix on the DNS names
NODE_ENV: ${{ secrets.NODE_ENV }}
DEMO_APP_NAME: demo-app
DEMO_IFRAME_APP_NAME: demo-iframe
STATIC_APP_NAME: static-app
NEXTJS_DEMO_APP_NAME: nextjs-demo
RELEASE_APP_NAME: release
AWS_REGION: us-east-2
jobs:
install-deps:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/configure-nodejs
with:
lookup-only: 'true' # We only want to lookup from the cache - if a hit, this job does nothing
build:
needs: [install-deps]
runs-on: ubuntu-latest
outputs:
prSuffix: ${{ steps.prSuffix.outputs.prSuffix }}
prSuffixPackageVersion: ${{ steps.prSuffix.outputs.prSuffixPackageVersion }}
releaseAppPackageVersion: ${{ steps.appVersions.outputs.releaseAppPackageVersion }}
nextjsDemoAppPackageVersion: ${{ steps.appVersions.outputs.nextjsDemoAppPackageVersion }}
steps:
- uses: actions/checkout@v4
- name: Compute PR Suffix
id: prSuffix
run: |
if [ -n "${PR_NUMBER}" ]; then
echo "prSuffix=-pr-${PR_NUMBER}" >> $GITHUB_OUTPUT
echo "prSuffixPackageVersion=-pr.${PR_NUMBER}" >> $GITHUB_OUTPUT
echo "PR_SUFFIX=-pr-"${PR_NUMBER} >> $GITHUB_ENV
else
echo "prSuffix=" >> $GITHUB_OUTPUT
echo "prSuffixPackageVersion=" >> $GITHUB_OUTPUT
echo "PR_SUFFIX=" >> $GITHUB_ENV
fi
- uses: ./.github/actions/configure-nodejs
# We do this here so the `build-jsii` modules are installed too
# and become part of the cache - if we don't then
# their install will get skipped during `build-jsii` but they won't
# be present in the cache so the build will fail
# - name: Optionally Install CDK Construct Deps
# if: steps.cache-node-modules.outputs.cache-hit != 'true'
# working-directory: packages/microapps-cdk/
# run: yarn install --frozen-lockfile
- name: Extract App NPM Versions
id: appVersions
run: |
# find . -type d -name microapps-app-nextjs-demo-cdk
echo 'NEXTJS_DEMO_APP_PACKAGE_VERSION='$(node -p -e "(require('./node_modules/@pwrdrvr/microapps-app-nextjs-demo-cdk/package.json')).version") >> $GITHUB_ENV
echo 'RELEASE_APP_PACKAGE_VERSION='$(node -p -e "(require('./node_modules/@pwrdrvr/microapps-app-release-cdk/package.json')).version") >> $GITHUB_ENV
echo "nextjsDemoAppPackageVersion=$(node -p -e "(require('./node_modules/@pwrdrvr/microapps-app-nextjs-demo-cdk/package.json')).version")" >> $GITHUB_OUTPUT
echo "releaseAppPackageVersion=$(node -p -e "(require('./node_modules/@pwrdrvr/microapps-app-release-cdk/package.json')).version")" >> $GITHUB_OUTPUT
- name: Versions
run: |
echo 'NEXTJS_DEMO_APP_PACKAGE_VERSION='${NEXTJS_DEMO_APP_PACKAGE_VERSION}
echo 'RELEASE_APP_PACKAGE_VERSION='${RELEASE_APP_PACKAGE_VERSION}
- name: Cache TypeScript Build Output
id: cache-typescript-build
uses: actions/cache@v4
with:
path: |
packages/**/dist
packages/microapps-cdk/lib
key: typescript-build-${{ hashFiles('package.json', 'yarn.lock', 'tsconfig.json', 'tsconfig.packages.json', 'packages/**/tsconfig.json', 'packages/**/*.ts') }}
- name: Optionally Build All TypeScript
if: steps.cache-typescript-build.outputs.cache-hit != 'true'
run: yarn build
- name: Run Lint
run: yarn lint
# - name: Run Node Tests
# env:
# NODE_ENV: test
# run: yarn test
test:
runs-on: ubuntu-latest
needs:
- build
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/configure-nodejs
- name: Cache TypeScript Build Output
id: cache-typescript-build
uses: actions/cache@v4
with:
path: |
packages/**/dist
packages/microapps-cdk/lib
key: typescript-build-${{ hashFiles('package.json', 'yarn.lock', 'tsconfig.json', 'tsconfig.packages.json', 'packages/**/tsconfig.json', 'packages/**/*.ts') }}
# These take 2 minutes on GHA
# Locally they take 16 seconds (M2 Max)
# Possible speedup: may need to replace jest-dynalite and switch to each
# test (or at least suite) creating a uniquely named table in a shared
# local dynamodb instance.
- name: Run Node Tests
env:
NODE_ENV: test
run: yarn test
deploy:
if: github.actor != 'dependabot[bot]'
strategy:
matrix:
deployName:
- microapps-core
- microapps-basic
- microapps-basic-prefix
exclude:
- deployName: ${{ (github.event_name != 'pull_request' || (github.event_name == 'pull_request' && contains( github.event.pull_request.labels.*.name, 'DEPLOY-BASIC'))) && 'dummy' || 'microapps-basic' }}
- deployName: ${{ (github.event_name != 'pull_request' || (github.event_name == 'pull_request' && contains( github.event.pull_request.labels.*.name, 'DEPLOY-BASIC-PREFIX'))) && 'dummy' || 'microapps-basic-prefix' }}
name: deploy-${{ matrix.deployName }}
concurrency:
group: deploy-${{ matrix.deployName }}-${{ github.workflow }}-${{ github.event.pull_request.number }}
cancel-in-progress: false
needs:
- build
environment:
name: ghpublic
url: https://${{ steps.getCDKExports.outputs.edgeDomain }}${{ steps.getCDKExports.outputs.prefix }}/${{ env.RELEASE_APP_NAME }}/
permissions:
contents: read
id-token: write
statuses: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Extract Current NPM Version
run: |
echo 'PACKAGE_VERSION_ORIG='$(node -p -e "require('./package.json').version") >> $GITHUB_ENV
- name: Compute NPM Version and App Lambda Name
run: |
echo 'PACKAGE_VERSION='${PACKAGE_VERSION_ORIG}${{ needs.build.outputs.prSuffixPackageVersion }} >> $GITHUB_ENV
- name: Set Prefix Path
run: |
if [ "${{ matrix.deployName }}" == "microapps-basic-prefix" ]; then
echo 'PREFIX=/prefix' >> $GITHUB_ENV
echo 'PREFIX_U=/u002Fprefix' >> $GITHUB_ENV
else
echo 'PREFIX=' >> $GITHUB_ENV
echo 'PREFIX_U=' >> $GITHUB_ENV
fi
- uses: ./.github/actions/configure-nodejs
# - name: Cache TypeScript Build Output
# id: cache-typescript-build
# uses: actions/cache@v4
# with:
# path: |
# packages/**/dist
# packages/microapps-cdk/lib
# key: typescript-build-${{ hashFiles('package.json', 'yarn.lock', 'tsconfig.json', 'tsconfig.packages.json', 'packages/**/tsconfig.json', 'packages/**/*.ts') }}
- name: Build All TypeScript
# if: steps.cache-typescript-build.outputs.cache-hit != 'true'
run: yarn build
- name: Build Edge-to-Origin for Local Deploy
run: yarn esbuild:edge-to-origin
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-session-name: microapps-ghpublic-build
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/builder-writeRole
aws-region: ${{ env.AWS_REGION }}
- name: Stitch Version and Prefix into Simple Demo App and Static App
run: |
npx replace-in-file "/\/0\.0\.0/g" ${PREFIX}/${PACKAGE_VERSION} --configFile=.demo-app-replace.config.js --isRegex
npx replace-in-file "/0\.0\.0/g" ${PACKAGE_VERSION} --configFile=.demo-app-replace.config.js --isRegex
npx replace-in-file "/0\.0\.0/g" ${PACKAGE_VERSION} --configFile=.static-app-replace.config.js --isRegex
- name: Stitch Prefix into Nextjs Demo App
run: |
if [ -n "${PREFIX}" ] ; then
npx replace-in-file "/\/${NEXTJS_DEMO_APP_NAME}/g" ${PREFIX}/${NEXTJS_DEMO_APP_NAME} --configFile=.nextjs-demo-replace.config.js --isRegex
npx replace-in-file "/\/u002F${NEXTJS_DEMO_APP_NAME}/g" ${PREFIX_U}/u002F${NEXTJS_DEMO_APP_NAME} --configFile=.nextjs-demo-replace.config.js --isRegex
fi
- name: Stitch Prefix into Release App
run: |
if [ -n "${PREFIX}" ] ; then
npx replace-in-file "/\/${RELEASE_APP_NAME}/g" ${PREFIX}/${RELEASE_APP_NAME} --configFile=.release-replace.config.js --isRegex
npx replace-in-file "/\/u002F${RELEASE_APP_NAME}/g" ${PREFIX_U}/u002F${RELEASE_APP_NAME} --configFile=.release-replace.config.js --isRegex
fi
#
# Synth and upload if BUILD-CDK-ZIP label is present
#
- name: Synth CDK Stack
if: github.event_name == 'pull_request' && contains( github.event.pull_request.labels.*.name, 'BUILD-CDK-ZIP')
run: |
npx cdk synth --context @pwrdrvr/microapps:deployDemoApp=true \
--context @pwrdrvr/microapps:deployNexjsDemoApp=true \
--context @pwrdrvr/microapps:deployReleaseApp=true \
--require-approval never ${{ matrix.deployName }}
- name: Zip Package
if: github.event_name == 'pull_request' && contains( github.event.pull_request.labels.*.name, 'BUILD-CDK-ZIP')
working-directory: .
run: zip -r cdk-out.zip cdk.out
- name: Upload Zip
if: github.event_name == 'pull_request' && contains( github.event.pull_request.labels.*.name, 'BUILD-CDK-ZIP')
uses: actions/upload-artifact@v4
with:
name: cdk_out_${{ matrix.deployName }}
path: cdk-out.zip
- name: Diff CDK Stack
run: |
npx cdk diff --context @pwrdrvr/microapps:deployDemoApp=true \
--context @pwrdrvr/microapps:deployNexjsDemoApp=true \
--context @pwrdrvr/microapps:deployReleaseApp=true \
--require-approval never ${{ matrix.deployName }}
- name: Set Hotswap Flag on PRs
run: |
if [ -n "${PR_NUMBER}" ]; then
echo "HOTSWAP_FLAG=" >> $GITHUB_ENV
else
echo "HOTSWAP_FLAG=" >> $GITHUB_ENV
fi
- name: Deploy CDK Stack
env:
AWS_ACCOUNT_ID_CHILD: ${{ secrets.AWS_ACCOUNT_ID_CHILD }}
run: |
npx cdk deploy \
${HOTSWAP_FLAG} \
--context @pwrdrvr/microapps:deployDemoApp=true \
--context @pwrdrvr/microapps:deployNexjsDemoApp=true \
--context @pwrdrvr/microapps:deployReleaseApp=true \
--require-approval never ${{ matrix.deployName }}
- name: Get CDK Exports
id: getCDKExports
run: |
echo "prefix="${PREFIX} >> $GITHUB_OUTPUT
echo "edgeDomain="$(aws cloudformation list-exports --query "Exports[?Name==\`${{ matrix.deployName }}-ghpublic-${NODE_ENV}${{ needs.build.outputs.prSuffix }}-edge-domain-name\`].Value" --output text) >> $GITHUB_OUTPUT
echo "EDGE_DOMAIN="$(aws cloudformation list-exports --query "Exports[?Name==\`${{ matrix.deployName }}-ghpublic-${NODE_ENV}${{ needs.build.outputs.prSuffix }}-edge-domain-name\`].Value" --output text) >> $GITHUB_ENV
echo "EDGE_TO_ORIGIN_ROLE_ARN="$(aws cloudformation list-exports --query "Exports[?Name==\`${{ matrix.deployName }}-ghpublic-${NODE_ENV}${{ needs.build.outputs.prSuffix }}-edge-role-role-arn\`].Value" --output text) >> $GITHUB_ENV
echo "DEPLOYER_LAMBDA_NAME="$(aws cloudformation list-exports --query "Exports[?Name==\`${{ matrix.deployName }}-ghpublic-${NODE_ENV}${{ needs.build.outputs.prSuffix }}-deployer-func-name\`].Value" --output text) >> $GITHUB_ENV
echo "DEPLOYER_LAMBDA_ARN="$(aws cloudformation list-exports --query "Exports[?Name==\`${{ matrix.deployName }}-ghpublic-${NODE_ENV}${{ needs.build.outputs.prSuffix }}-deployer-func-arn\`].Value" --output text) >> $GITHUB_ENV
echo "DEMO_APP_LAMBDA_NAME="$(aws cloudformation list-exports --query "Exports[?Name==\`${{ matrix.deployName }}-ghpublic-${NODE_ENV}${{ needs.build.outputs.prSuffix }}-demo-app-func-name\`].Value" --output text) >> $GITHUB_ENV
echo "DEMO_APP_LAMBDA_VERSION_ARN="$(aws cloudformation list-exports --query "Exports[?Name==\`${{ matrix.deployName }}-ghpublic-${NODE_ENV}${{ needs.build.outputs.prSuffix }}-demo-app-vers-arn\`].Value" --output text) >> $GITHUB_ENV
echo "NEXTJS_DEMO_APP_LAMBDA_NAME="$(aws cloudformation list-exports --query "Exports[?Name==\`${{ matrix.deployName }}-ghpublic-${NODE_ENV}${{ needs.build.outputs.prSuffix }}-nextjs-demo-app-func-name\`].Value" --output text) >> $GITHUB_ENV
echo "NEXTJS_DEMO_APP_LAMBDA_VERSION_ARN="$(aws cloudformation list-exports --query "Exports[?Name==\`${{ matrix.deployName }}-ghpublic-${NODE_ENV}${{ needs.build.outputs.prSuffix }}-nextjs-demo-app-vers-arn\`].Value" --output text) >> $GITHUB_ENV
echo "RELEASE_APP_LAMBDA_NAME="$(aws cloudformation list-exports --query "Exports[?Name==\`${{ matrix.deployName }}-ghpublic-${NODE_ENV}${{ needs.build.outputs.prSuffix }}-release-app-func-name\`].Value" --output text) >> $GITHUB_ENV
echo "RELEASE_APP_LAMBDA_VERSION_ARN="$(aws cloudformation list-exports --query "Exports[?Name==\`${{ matrix.deployName }}-ghpublic-${NODE_ENV}${{ needs.build.outputs.prSuffix }}-release-app-vers-arn\`].Value" --output text) >> $GITHUB_ENV
- name: Echo Exports
run: |
env | grep EDGE_
env | grep DEPLOYER_
env | grep DEMO_APP_
env | grep NEXTJS_DEMO_APP_
env | grep RELEASE_APP_
- name: Publish URL App to MicroApps
run: |
npx pwrdrvr publish \
--app-name blog \
--type url \
--new-version ${PACKAGE_VERSION} \
--deployer-lambda-name ${DEPLOYER_LAMBDA_NAME} \
--url https://www.pwrdrvr.com \
--overwrite
- name: Publish Static App to Child MicroApps
run: |
npx pwrdrvr publish-static \
--app-name ${STATIC_APP_NAME} \
--new-version 0.0.0 \
--deployer-lambda-name ${DEPLOYER_LAMBDA_ARN} \
--static-assets-path packages/static-app/src \
--default-file index.html \
--overwrite
- name: Publish Demo App to MicroApps
run: |
npx pwrdrvr publish \
--app-name ${DEMO_APP_NAME} \
--type lambda-url \
--startup-type direct \
--new-version 0.0.0 \
--deployer-lambda-name ${DEPLOYER_LAMBDA_NAME} \
--app-lambda-name ${DEMO_APP_LAMBDA_NAME} \
--static-assets-path packages/demo-app/static_files \
--default-file index.html \
--overwrite
- name: Demo App URL
uses: actions/github-script@v7
with:
script: |
await github.rest.repos.createCommitStatus({
owner: '${{ github.repository_owner }}',
repo: '${{ github.event.repository.name }}',
sha: '${{github.event.pull_request.head.sha || github.sha}}',
context: 'Demo App URL on ${{ matrix.deployName }}',
state: 'success',
description: 'Passed',
target_url: `https://${{ steps.getCDKExports.outputs.edgeDomain }}${{ steps.getCDKExports.outputs.prefix }}/${{ env.DEMO_APP_NAME }}/?appver=0.0.0`
});
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Test Demo App
run: |
echo Testing App Frame Loading
curl -H"accept: text/html" --fail https://${EDGE_DOMAIN}${PREFIX}/${DEMO_APP_NAME}/
echo Testing App HTML Loading
curl -H"accept: text/html" --fail https://${EDGE_DOMAIN}${PREFIX}/${DEMO_APP_NAME}/0.0.0/index.html
echo Testing App Method Invocation
curl -H"accept: application/json" --fail "https://${EDGE_DOMAIN}${PREFIX}/${DEMO_APP_NAME}/0.0.0/serverIncrement?currValue=1"
echo Testing App Method Invocation on _next/data Route
curl -H"accept: application/json" --fail "https://${EDGE_DOMAIN}${PREFIX}/${DEMO_APP_NAME}/_next/data/0.0.0/serverIncrement?currValue=1"
- name: Publish Demo App to MicroApps as iFrame App + API
run: |
npx pwrdrvr publish \
--app-name ${DEMO_IFRAME_APP_NAME} \
--type lambda-url \
--startup-type iframe \
--new-version 0.0.0 \
--deployer-lambda-name ${DEPLOYER_LAMBDA_NAME} \
--app-lambda-name ${DEMO_APP_LAMBDA_NAME} \
--static-assets-path packages/demo-app/static_files \
--default-file index.html \
--overwrite
- name: Demo IFrame App URL
uses: actions/github-script@v7
with:
script: |
await github.rest.repos.createCommitStatus({
owner: '${{ github.repository_owner }}',
repo: '${{ github.event.repository.name }}',
sha: '${{github.event.pull_request.head.sha || github.sha}}',
context: 'Demo IFrame App URL on ${{ matrix.deployName }}',
state: 'success',
description: 'Passed',
target_url: `https://${{ steps.getCDKExports.outputs.edgeDomain }}${{ steps.getCDKExports.outputs.prefix }}/${{ env.DEMO_IFRAME_APP_NAME }}?appver=${{ env.PACKAGE_VERSION }}`
});
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Test Demo IFrame App
run: |
echo Testing App Frame Loading
curl -H"accept: text/html" --fail https://${EDGE_DOMAIN}${PREFIX}/${DEMO_IFRAME_APP_NAME}/
echo Testing App HTML Loading
curl -H"accept: text/html" --fail https://${EDGE_DOMAIN}${PREFIX}/${DEMO_IFRAME_APP_NAME}/0.0.0/index.html
echo Testing App Method Invocation
curl -H"accept: application/json" --fail "https://${EDGE_DOMAIN}${PREFIX}/${DEMO_IFRAME_APP_NAME}/0.0.0/serverIncrement?currValue=1"
echo Testing App Method Invocation on _next/data Route
curl -H"accept: application/json" --fail "https://${EDGE_DOMAIN}${PREFIX}/${DEMO_IFRAME_APP_NAME}/api/serverIncrement?currValue=1"
- name: Publish Demo App to MicroApps - To Delete
run: |
npx pwrdrvr publish \
--app-name ${DEMO_APP_NAME} \
--type lambda-url \
--startup-type direct \
--new-version 0.0.0-delete.1 \
--deployer-lambda-name ${DEPLOYER_LAMBDA_NAME} \
--app-lambda-name ${DEMO_APP_LAMBDA_NAME} \
--static-assets-path packages/demo-app/static_files \
--default-file index.html \
--overwrite \
--no-cache
- name: Delete Demo App - To Delete
run: |
npx pwrdrvr delete \
--app-name ${DEMO_APP_NAME} \
--new-version 0.0.0-delete.1 \
--deployer-lambda-name ${DEPLOYER_LAMBDA_NAME}
- name: Publish Demo App to MicroApps - Root App
run: |
npx pwrdrvr publish \
--app-name '[root]' \
--type lambda-url \
--startup-type direct \
--new-version 0.0.0 \
--deployer-lambda-name ${DEPLOYER_LAMBDA_NAME} \
--app-lambda-name ${DEMO_APP_LAMBDA_NAME} \
--static-assets-path packages/demo-app/static_files \
--default-file index.html \
--overwrite
- name: Demo App URL - Root App
uses: actions/github-script@v7
with:
script: |
await github.rest.repos.createCommitStatus({
owner: '${{ github.repository_owner }}',
repo: '${{ github.event.repository.name }}',
sha: '${{github.event.pull_request.head.sha || github.sha}}',
context: 'Demo App (Root App) URL on ${{ matrix.deployName }}',
state: 'success',
description: 'Passed',
target_url: `https://${{ steps.getCDKExports.outputs.edgeDomain }}${{ steps.getCDKExports.outputs.prefix }}/?appver=${{ env.PACKAGE_VERSION }}`
});
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Test Demo App - Root App
run: |
echo Testing App Frame Loading
curl -H"accept: text/html" --fail https://${EDGE_DOMAIN}${PREFIX}/
echo Testing App HTML Loading
curl -H"accept: text/html" --fail https://${EDGE_DOMAIN}${PREFIX}/0.0.0/index.html
echo Testing App Method Invocation
curl -H"accept: application/json" --fail "https://${EDGE_DOMAIN}${PREFIX}/0.0.0/serverIncrement?currValue=1"
echo Testing App Method Invocation on _next/data Route
curl -H"accept: application/json" --fail "https://${EDGE_DOMAIN}${PREFIX}/_next/data/0.0.0/serverIncrement?currValue=1"
- name: Publish Nextjs Demo App to MicroApps
run: |
npx pwrdrvr publish \
--app-name ${NEXTJS_DEMO_APP_NAME} \
--type lambda-url \
--startup-type direct \
--new-version ${{ needs.build.outputs.nextjsDemoAppPackageVersion }} \
--deployer-lambda-name ${DEPLOYER_LAMBDA_NAME} \
--app-lambda-name ${NEXTJS_DEMO_APP_LAMBDA_VERSION_ARN} \
--static-assets-path node_modules/@pwrdrvr/microapps-app-nextjs-demo-cdk/lib/microapps-app-nextjs-demo/static_files/ \
--overwrite
- name: Nextjs Demo App URL
uses: actions/github-script@v7
with:
script: |
await github.rest.repos.createCommitStatus({
owner: '${{ github.repository_owner }}',
repo: '${{ github.event.repository.name }}',
sha: '${{github.event.pull_request.head.sha || github.sha}}',
context: 'Nextjs Demo App URL on ${{ matrix.deployName }}',
state: 'success',
description: 'Passed',
target_url: `https://${{ steps.getCDKExports.outputs.edgeDomain }}${{ steps.getCDKExports.outputs.prefix }}/${{ env.NEXTJS_DEMO_APP_NAME }}?appver=${{ needs.build.outputs.nextjsDemoAppPackageVersion }}`
});
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Test Nextjs Demo App
if: ${{ matrix.deployName != 'microapps-basic-prefix' }}
run: |
echo Testing App Page Loading
curl -H"accept: text/html" --fail https://${EDGE_DOMAIN}${PREFIX}/${NEXTJS_DEMO_APP_NAME}
echo Testing App HTML Loading
curl -H"accept: text/html" --fail https://${EDGE_DOMAIN}${PREFIX}/${NEXTJS_DEMO_APP_NAME}?appver=${{ needs.build.outputs.nextjsDemoAppPackageVersion }}
echo Testing Post Page Loading
curl -H"accept: text/html" --fail https://${EDGE_DOMAIN}${PREFIX}/${NEXTJS_DEMO_APP_NAME}/posts/pre-rendering?appver=${{ needs.build.outputs.nextjsDemoAppPackageVersion }}
- name: Publish Release App to MicroApps
run: |
npx pwrdrvr publish \
--app-name ${RELEASE_APP_NAME} \
--type lambda-url \
--startup-type direct \
--new-version ${{ needs.build.outputs.releaseAppPackageVersion }} \
--deployer-lambda-name ${DEPLOYER_LAMBDA_NAME} \
--app-lambda-name ${RELEASE_APP_LAMBDA_VERSION_ARN} \
--static-assets-path node_modules/@pwrdrvr/microapps-app-release-cdk/lib/microapps-app-release/static_files/ \
--overwrite
- name: Release App URL
uses: actions/github-script@v7
with:
script: |
await github.rest.repos.createCommitStatus({
owner: '${{ github.repository_owner }}',
repo: '${{ github.event.repository.name }}',
sha: '${{github.event.pull_request.head.sha || github.sha}}',
context: 'Release App URL on ${{ matrix.deployName }}',
state: 'success',
description: 'Passed',
target_url: `https://${{ steps.getCDKExports.outputs.edgeDomain }}${{ steps.getCDKExports.outputs.prefix }}/${{ env.RELEASE_APP_NAME }}?appver=${{ needs.build.outputs.releaseAppPackageVersion }}`
});
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Test Release App
if: ${{ matrix.deployName != 'microapps-basic-prefix' }}
run: |
echo Testing App Frame Loading
curl -H"accept: text/html" --fail https://${EDGE_DOMAIN}${PREFIX}/${RELEASE_APP_NAME}
echo Testing App HTML Loading
curl -H"accept: text/html" --fail https://${EDGE_DOMAIN}${PREFIX}/${RELEASE_APP_NAME}?appver=${{ needs.build.outputs.releaseAppPackageVersion }}
echo Testing App Method Invocation
curl -H"accept: application/json" --fail https://${EDGE_DOMAIN}${PREFIX}/${RELEASE_APP_NAME}/${{ needs.build.outputs.releaseAppPackageVersion }}/api/refresh/${DEMO_APP_NAME}
#
# Child Account Deploy
#
# Change to Child Account Creds
- name: Change to Child Account
if: ${{ matrix.deployName == 'microapps-core' }}
uses: aws-actions/configure-aws-credentials@v4
with:
role-session-name: microapps-ghpublic-build
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID_CHILD }}:role/builder-writeRole
aws-region: ${{ env.AWS_REGION }}
- name: Deploy Child CDK Stack
if: ${{ matrix.deployName == 'microapps-core' }}
env:
PARENT_DEPLOYER_LAMBDA_ARN: ${{ env.DEPLOYER_LAMBDA_ARN }}
run: |
npx cdk deploy \
${HOTSWAP_FLAG} \
--require-approval never ${{ matrix.deployName }}-child
- name: Get Child CDK Exports
if: ${{ matrix.deployName == 'microapps-core' }}
id: getChildCDKExports
run: |
echo "CHILD_DEPLOYER_LAMBDA_ARN="$(aws cloudformation list-exports --query "Exports[?Name==\`${{ matrix.deployName }}-ghchild-${NODE_ENV}${{ needs.build.outputs.prSuffix }}-deployer-func-arn\`].Value" --output text) >> $GITHUB_ENV
echo "CHILD_DEMO_APP_LAMBDA_NAME="$(aws cloudformation list-exports --query "Exports[?Name==\`${{ matrix.deployName }}-ghchild-${NODE_ENV}${{ needs.build.outputs.prSuffix }}-demo-app-func-name\`].Value" --output text) >> $GITHUB_ENV
echo "CHILD_DEMO_APP_LAMBDA_VERSION_ARN="$(aws cloudformation list-exports --query "Exports[?Name==\`${{ matrix.deployName }}-ghchild-${NODE_ENV}${{ needs.build.outputs.prSuffix }}-demo-app-vers-arn\`].Value" --output text) >> $GITHUB_ENV
- name: Echo Exports
if: ${{ matrix.deployName == 'microapps-core' }}
run: |
env | grep CHILD_
- name: Change Back to Parent AWS Account
if: ${{ matrix.deployName == 'microapps-core' }}
uses: aws-actions/configure-aws-credentials@v4
with:
role-session-name: microapps-ghpublic-build
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/builder-writeRole
aws-region: ${{ env.AWS_REGION }}
- name: Allow Child Deployer to Invoke Parent Deployer
if: ${{ matrix.deployName == 'microapps-core' }}
env:
PARENT_DEPLOYER_LAMBDA_ARN: ${{ env.DEPLOYER_LAMBDA_ARN }}
AWS_ACCOUNT_ID_CHILD: ${{ secrets.AWS_ACCOUNT_ID_CHILD }}
run: |
npx cdk deploy \
--require-approval never ${{ matrix.deployName }}-child-priv
- name: Change Back to Child Account
if: ${{ matrix.deployName == 'microapps-core' }}
uses: aws-actions/configure-aws-credentials@v4
with:
role-session-name: microapps-ghpublic-build
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID_CHILD }}:role/builder-writeRole
aws-region: ${{ env.AWS_REGION }}
- name: Publish Demo App to Child MicroApps - To Delete
if: ${{ matrix.deployName == 'microapps-core' }}
run: |
npx pwrdrvr publish \
--app-name ${DEMO_APP_NAME} \
--type lambda-url \
--startup-type direct \
--new-version 0.0.0-childDelete.1 \
--deployer-lambda-name ${CHILD_DEPLOYER_LAMBDA_ARN} \
--app-lambda-name ${CHILD_DEMO_APP_LAMBDA_NAME} \
--static-assets-path packages/demo-app/static_files \
--default-file index.html \
--overwrite
- name: Delete Demo App from Child MicroApps - To Delete
if: ${{ matrix.deployName == 'microapps-core' }}
run: |
npx pwrdrvr delete \
--app-name ${DEMO_APP_NAME} \
--new-version 0.0.0-childDelete.1 \
--deployer-lambda-name ${CHILD_DEPLOYER_LAMBDA_ARN}
- name: Publish Demo App to Child MicroApps
if: ${{ matrix.deployName == 'microapps-core' }}
run: |
npx pwrdrvr publish \
--app-name ${DEMO_APP_NAME} \
--type lambda-url \
--startup-type direct \
--new-version 0.0.0-child.1 \
--deployer-lambda-name ${CHILD_DEPLOYER_LAMBDA_ARN} \
--app-lambda-name ${CHILD_DEMO_APP_LAMBDA_NAME} \
--static-assets-path packages/demo-app/static_files \
--default-file index.html \
--overwrite
- name: Test Demo App - Child
if: ${{ matrix.deployName == 'microapps-core' }}
run: |
echo Testing App Frame Loading
curl -H"accept: text/html" --fail https://${EDGE_DOMAIN}${PREFIX}/${DEMO_APP_NAME}/
echo Testing App HTML Loading
curl -H"accept: text/html" --fail https://${EDGE_DOMAIN}${PREFIX}/${DEMO_APP_NAME}/0.0.0-child.1/index.html
echo Testing App Method Invocation
curl -H"accept: application/json" --fail "https://${EDGE_DOMAIN}${PREFIX}/${DEMO_APP_NAME}/0.0.0-child.1/serverIncrement?currValue=1"
echo Testing App Method Invocation on _next/data Route
curl -H"accept: application/json" --fail "https://${EDGE_DOMAIN}${PREFIX}/${DEMO_APP_NAME}/_next/data/0.0.0-child.1/serverIncrement?currValue=1"
- name: Run Integration Tests
env:
BASE_URL: https://${{ env.EDGE_DOMAIN }}${{ env.PREFIX }}/
DEMO_AND_ROOT_APP_VER: '0.0.0' # '${{ env.PACKAGE_VERSION }}'
NEXTJS_DEMO_APP_VER: '${{ needs.build.outputs.nextjsDemoAppPackageVersion }}'
DEPLOY_NAME: ${{ matrix.deployName }}
run: |
npm run test:integration
build-jsii:
# if: github.event_name != 'pull_request' || (github.event_name == 'pull_request' && contains( github.event.pull_request.labels.*.name, 'BUILD-JSII')) || (github.event_name == 'pull_request' && github.actor == 'dependabot[bot]')
needs: [install-deps]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/configure-nodejs
- name: Modify microapps-cdk tsconfig.json
run: |
mv packages/microapps-cdk/tsconfig.json packages/microapps-cdk/tsconfig.jsii.json
jq ".compilerOptions += { \"skipLibCheck\": true }" packages/microapps-cdk/tsconfig.jsii.json > packages/microapps-cdk/tsconfig.json
- name: Build All TypeScript
run: yarn build
- name: Install CDK Construct Deps
working-directory: packages/microapps-cdk/
run: yarn install --frozen-lockfile
- name: Build CDK Construct
working-directory: packages/microapps-cdk/
run: |
yarn build
- name: Confirm No Doc Changes
working-directory: packages/microapps-cdk/
run: |
yarn post-compile
git diff --ignore-space-at-eol --exit-code