Update system #42
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: Main | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| id-token: write | |
| contents: read | |
| steps: | |
| - name: Setup job workspace | |
| uses: ServerlessOpsIO/gha-setup-workspace@v1 | |
| - name: Assume AWS Credentials | |
| uses: ServerlessOpsIO/gha-assume-aws-credentials@v1 | |
| with: | |
| build_aws_account_id: ${{ secrets.AWS_CICD_ACCOUNT_ID }} | |
| - name: Install AWS SAM | |
| uses: aws-actions/setup-sam@v2 | |
| - name: Validate template | |
| run: sam validate --lint | |
| - name: Validate template (userpool stackset) | |
| run: sam validate --lint --template ./stacksets/userpool/stackset.yaml | |
| - name: Validate template (products stackset) | |
| run: sam validate --lint --template ./products/stackset.yaml | |
| - name: Validate template (client product) | |
| run: sam validate --lint --template ./products/client/product.yaml | |
| - name: Validate template (server product) | |
| run: sam validate --lint --template ./products/server/product.yaml | |
| - name: Synethsize StackSet templates | |
| run: | | |
| for _f in $(find . -type f -name 'template.yaml'); do | |
| _dir="$(dirname $_f)/" \ | |
| yq \ | |
| -i \ | |
| '(.. | select(has("localTemplateFile")) | .localTemplateFile) |= load_str(strenv(_dir) + .)' \ | |
| $_f; | |
| done | |
| - name: Store Artifacts | |
| uses: ServerlessOpsIO/gha-store-artifacts@v1 | |
| with: | |
| use_aws_sam: true | |
| deploy: | |
| needs: | |
| - build | |
| environment: production | |
| runs-on: ubuntu-latest | |
| permissions: | |
| id-token: write | |
| contents: read | |
| steps: | |
| - name: Setup job workspace | |
| uses: ServerlessOpsIO/gha-setup-workspace@v1 | |
| with: | |
| checkout_artifact: true | |
| - name: Assume AWS Credentials | |
| uses: ServerlessOpsIO/gha-assume-aws-credentials@v1 | |
| with: | |
| build_aws_account_id: ${{ secrets.AWS_CICD_ACCOUNT_ID }} | |
| deploy_aws_account_id: ${{ secrets.AWS_MANAGEMENT_ACCOUNT_ID }} | |
| - name: Sync product templates to S3 | |
| id: sync-templates | |
| shell: bash | |
| env: | |
| AWS_ACCOUNT_ID: ${{ secrets.AWS_MANAGEMENT_ACCOUNT_ID }} | |
| run: aws s3 sync products/ s3://aws-service-catalog-templates-${AWS_ACCOUNT_ID}-${AWS_REGION}/serverlessops-api-authnz/${GITHUB_SHA}/ | |
| - name: Deploy via AWS SAM | |
| uses: ServerlessOpsIO/gha-deploy-aws-sam@v1 | |
| with: | |
| aws_account_id: ${{ secrets.AWS_MANAGEMENT_ACCOUNT_ID }} | |
| env_json: ${{ toJson(env) }} | |
| secrets_json: ${{ toJson(secrets) }} |