|
| 1 | +name: Branches |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + push: |
| 6 | + branches-ignore: |
| 7 | + - 'main' |
| 8 | + |
| 9 | +jobs: |
| 10 | + build: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + permissions: |
| 13 | + id-token: write |
| 14 | + contents: read |
| 15 | + |
| 16 | + steps: |
| 17 | + - name: Setup job workspace |
| 18 | + uses: ServerlessOpsIO/gha-setup-workspace@v1 |
| 19 | + |
| 20 | + - name: Assume AWS Credentials |
| 21 | + uses: ServerlessOpsIO/gha-assume-aws-credentials@v1 |
| 22 | + with: |
| 23 | + build_aws_account_id: ${{ secrets.AWS_CICD_ACCOUNT_ID }} |
| 24 | + |
| 25 | + - name: Install AWS SAM |
| 26 | + uses: aws-actions/setup-sam@v2 |
| 27 | + |
| 28 | + - name: Validate artifact (deploy) |
| 29 | + run: sam validate --lint -t stackset-deploy-template.yaml |
| 30 | + |
| 31 | + - name: Validate artifact (build) |
| 32 | + run: sam validate --lint -t stackset-build-template.yaml |
| 33 | + |
| 34 | + - name: Validate artifact (SAM artifact) |
| 35 | + run: sam validate --lint -t stacksets/gha-build/sam-deployment.yaml |
| 36 | + |
| 37 | + - name: Validate artifact (build stackset) |
| 38 | + run: sam validate --lint -t stacksets/gha-build/stackset.yaml |
| 39 | + |
| 40 | + - name: Validate artifact (deploy stackset) |
| 41 | + run: sam validate --lint -t stacksets/gha-deploy/stackset.yaml |
| 42 | + |
| 43 | + - name: Synethsize StackSet templates |
| 44 | + run: | |
| 45 | + for _f in $(find . -type f -name 'stackset-*-template.yaml'); do |
| 46 | + _dir="$(dirname $_f)/" \ |
| 47 | + yq \ |
| 48 | + -i \ |
| 49 | + '(.. | select(has("localTemplateFile")) | .localTemplateFile) |= load_str(strenv(_dir) + .)' \ |
| 50 | + $_f; |
| 51 | + done |
| 52 | +
|
| 53 | + - name: Upload SAM artifact (Management Account / GHA Deploy) |
| 54 | + id: upload-sam-gha-template |
| 55 | + shell: bash |
| 56 | + run: | |
| 57 | + sam package \ |
| 58 | + --template stacksets/gha-deploy/stackset.yaml \ |
| 59 | + --s3-bucket aws-sam-cli-sourcebucket-225989329251-us-east-1 \ |
| 60 | + --s3-prefix ${{ env.GITHUB_REPOSITORY_OWNER_PART_SLUG_URL }}/${{ env.GITHUB_REPOSITORY_NAME_PART_SLUG_URL }}/${{ env.GITHUB_REF_SLUG_URL }} \ |
| 61 | + --region us-east-1 \ |
| 62 | + --output-template-file packaged-gha-deploy-template.yaml |
| 63 | +
|
| 64 | + - name: Upload SAM artifact (Management Account / CFN CR) |
| 65 | + id: upload-sam-cfncr-template |
| 66 | + shell: bash |
| 67 | + run: | |
| 68 | + sam package \ |
| 69 | + --template stacksets/cfn-custom-resource-deploy/stackset.yaml \ |
| 70 | + --s3-bucket aws-sam-cli-sourcebucket-225989329251-us-east-1 \ |
| 71 | + --s3-prefix ${{ env.GITHUB_REPOSITORY_OWNER_PART_SLUG_URL }}/${{ env.GITHUB_REPOSITORY_NAME_PART_SLUG_URL }}/${{ env.GITHUB_REF_SLUG_URL }} \ |
| 72 | + --region us-east-1 \ |
| 73 | + --output-template-file packaged-cfncr-template.yaml |
| 74 | +
|
| 75 | + - name: Upload SAM artifact (Build Account) |
| 76 | + id: upload-sam-stackset-build-template |
| 77 | + shell: bash |
| 78 | + run: | |
| 79 | + sam package \ |
| 80 | + --template stackset-build-template.yaml \ |
| 81 | + --s3-bucket aws-sam-cli-sourcebucket-225989329251-us-east-1 \ |
| 82 | + --s3-prefix ${{ env.GITHUB_REPOSITORY_OWNER_PART_SLUG_URL }}/${{ env.GITHUB_REPOSITORY_NAME_PART_SLUG_URL }}/${{ env.GITHUB_REF_SLUG_URL }} \ |
| 83 | + --region us-east-1 \ |
| 84 | + --output-template-file packaged-stackset-build-template.yaml |
| 85 | +
|
| 86 | + - name: Upload SAM artifact (Deploy Account) |
| 87 | + id: upload-sam-stackset-deploy-template |
| 88 | + shell: bash |
| 89 | + run: | |
| 90 | + sam package \ |
| 91 | + --template stackset-deploy-template.yaml \ |
| 92 | + --s3-bucket aws-sam-cli-sourcebucket-225989329251-us-east-1 \ |
| 93 | + --s3-prefix ${{ env.GITHUB_REPOSITORY_OWNER_PART_SLUG_URL }}/${{ env.GITHUB_REPOSITORY_NAME_PART_SLUG_URL }}/${{ env.GITHUB_REF_SLUG_URL }} \ |
| 94 | + --region us-east-1 \ |
| 95 | + --output-template-file packaged-stackset-deploy-template.yaml |
| 96 | +
|
| 97 | + - name: Store Artifacts |
| 98 | + uses: ServerlessOpsIO/gha-store-artifacts@v1 |
0 commit comments