Stack Deployment #31
This file contains 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: Stack Deployment | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
paths: | |
- "cdk/lib/**" | |
- "cdk/bin/**" | |
permissions: | |
id-token: write # This is required for requesting the JWT | |
contents: read # This is required for actions/checkout | |
jobs: | |
deploy: | |
name: Deployment | |
runs-on: ubuntu-latest | |
env: | |
AWS_REGION: ${{ secrets.AWS_REGION }} | |
steps: | |
- name: Git clone the repository | |
uses: actions/checkout@v3 | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v2 | |
with: | |
role-to-assume: ${{ secrets.AWS_CDK_ROLE_ARN }} | |
role-session-name: docs-site-template-deploy | |
aws-region: ${{ env.AWS_REGION }} | |
- name: Setup Node.js environment | |
uses: actions/[email protected] | |
with: | |
node-version: lts/* | |
- name: Installing dependencies | |
working-directory: cdk | |
run: npm install | |
- name: Deployment | |
working-directory: cdk | |
run: npm run deploy -- --require-approval never --outputs-file ./cdk-outputs.json | |
- name: CDK Output | |
id: cdk_output | |
run: | | |
CDK_OUTPUT=$(cat cdk/cdk-outputs.json) | |
echo "CDK Output:" >> $GITHUB_STEP_SUMMARY | |
echo '```json' >> $GITHUB_STEP_SUMMARY | |
echo "$CDK_OUTPUT" >> $GITHUB_STEP_SUMMARY | |
echo '```' >> $GITHUB_STEP_SUMMARY | |
echo "BucketName=$(echo $CDK_OUTPUT | jq -r '.DocsSiteTemplate.BucketName')" >> $GITHUB_OUTPUT | |
echo "DistributionId=$(echo $CDK_OUTPUT | jq -r '.DocsSiteTemplate.DistributionId')" >> $GITHUB_OUTPUT | |
echo "WebsiteUrl=$(echo $CDK_OUTPUT | jq -r '.DocsSiteTemplate.WebsiteUrl')" >> $GITHUB_OUTPUT | |
cat $GITHUB_OUTPUT | |
- name: Deploy dynamic variables | |
env: | |
GH_TOKEN: ${{ secrets.GH_SECRETS_TOKEN }} | |
run: | | |
gh variable set AWS_BUCKET_NAME --body "${{ steps.cdk_output.outputs.BucketName }}" --env aws-development | |
gh variable set AWS_DISTRIBUTION_ID --body "${{ steps.cdk_output.outputs.DistributionId }}" --env aws-development | |
gh variable set AWS_WEBSITE_URL --body "${{ steps.cdk_output.outputs.WebsiteUrl }}" --env aws-development | |
- name: Archive stack artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: cdk-output | |
path: | | |
cdk/cdk-outputs.json |