chrisqm-dev is testing out GitHub Actions π #18
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: GitHub CloudFormation Deployment | |
| run-name: ${{ github.actor }} is testing out GitHub Actions π | |
| on: | |
| push: | |
| workflow_dispatch: | |
| permissions: | |
| id-token: write # This is required for requesting the JWT | |
| contents: read # This is required for actions/checkout | |
| jobs: | |
| Explore-GitHub-Actions: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out repository code | |
| uses: actions/checkout@v3 | |
| - name: Configure AWS credentials from Test account | |
| uses: aws-actions/configure-aws-credentials@v1 | |
| with: | |
| role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }} | |
| aws-region: us-east-1 | |
| - name: Deploy | |
| uses: aws-actions/aws-cloudformation-github-deploy@master | |
| with: | |
| name: TestGitHubAction | |
| template: stack.yaml | |
| parameter-overrides: >- | |
| Environment=beta, | |
| AList="value1,value2" | |
| test-long-running: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 120 | |
| steps: | |
| - name: Check out repository code | |
| uses: actions/checkout@v3 | |
| - name: Configure AWS credentials from Test account | |
| uses: aws-actions/configure-aws-credentials@v1 | |
| with: | |
| role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }} | |
| aws-region: us-east-1 | |
| role-duration-seconds: 7200 | |
| - name: Test long-running stack (70 minutes) | |
| uses: aws-actions/aws-cloudformation-github-deploy@master | |
| with: | |
| name: test-long-running-${{ github.run_number }}-${{ github.run_attempt }} | |
| template: long-running-stack.yaml | |
| capabilities: "CAPABILITY_IAM" | |
| timeout-in-minutes: 90 | |
| test-no-execute-changeset: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out repository code | |
| uses: actions/checkout@v3 | |
| - name: Configure AWS credentials from Test account | |
| uses: aws-actions/configure-aws-credentials@v1 | |
| with: | |
| role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }} | |
| aws-region: us-east-1 | |
| - name: Cleanup existing stack if present | |
| run: | | |
| STACK_NAME="test-no-execute-changeset-${{ github.run_number }}-${{ github.run_attempt }}" | |
| if aws cloudformation describe-stacks --stack-name $STACK_NAME 2>/dev/null; then | |
| echo "Stack exists, deleting it first..." | |
| aws cloudformation delete-stack --stack-name $STACK_NAME | |
| aws cloudformation wait stack-delete-complete --stack-name $STACK_NAME | |
| fi | |
| - name: Deploy with no-execute-changeset=1 (should create stack in REVIEW_IN_PROGRESS) | |
| uses: aws-actions/aws-cloudformation-github-deploy@master | |
| with: | |
| name: test-no-execute-changeset-${{ github.run_number }}-${{ github.run_attempt }} | |
| template: no-execute-changeset-test.yaml | |
| capabilities: "CAPABILITY_IAM" | |
| no-execute-changeset: "1" | |
| - name: Verify stack is in REVIEW_IN_PROGRESS status | |
| run: | | |
| STACK_NAME="test-no-execute-changeset-${{ github.run_number }}-${{ github.run_attempt }}" | |
| echo "Checking stack status after deployment with no-execute-changeset=1..." | |
| STACK_STATUS=$(aws cloudformation describe-stacks --stack-name $STACK_NAME --query 'Stacks[0].StackStatus' --output text) | |
| echo "Stack status: $STACK_STATUS" | |
| if [ "$STACK_STATUS" = "REVIEW_IN_PROGRESS" ]; then | |
| echo "β SUCCESS: Stack is in REVIEW_IN_PROGRESS status as expected" | |
| else | |
| echo "β FAILURE: Stack status is $STACK_STATUS, expected REVIEW_IN_PROGRESS" | |
| echo "This indicates the bug is present - the changeset was executed despite no-execute-changeset=1" | |
| exit 1 | |
| fi | |
| - name: Cleanup test stack | |
| if: always() | |
| run: | | |
| STACK_NAME="test-no-execute-changeset-${{ github.run_number }}-${{ github.run_attempt }}" | |
| if aws cloudformation describe-stacks --stack-name $STACK_NAME 2>/dev/null; then | |
| aws cloudformation delete-stack --stack-name $STACK_NAME | |
| aws cloudformation wait stack-delete-complete --stack-name $STACK_NAME | |
| echo "Test stack cleaned up successfully" | |
| fi |