|
| 1 | +name: Branches |
| 2 | +on: |
| 3 | + workflow_dispatch: |
| 4 | + push: |
| 5 | + branches-ignore: |
| 6 | + - main |
| 7 | + |
| 8 | +jobs: |
| 9 | + build: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + permissions: |
| 12 | + id-token: write |
| 13 | + contents: read |
| 14 | + |
| 15 | + steps: |
| 16 | + - name: Setup job workspace |
| 17 | + uses: ServerlessOpsIO/gha-setup-workspace@v1 |
| 18 | + |
| 19 | + - name: Assume AWS credentials |
| 20 | + uses: ServerlessOpsIO/gha-assume-aws-credentials@v1 |
| 21 | + with: |
| 22 | + build_aws_account_id: ${{ secrets.AWS_CICD_ACCOUNT_ID }} |
| 23 | + |
| 24 | + - name: Install AWS SAM |
| 25 | + uses: aws-actions/setup-sam@v2 |
| 26 | + |
| 27 | + - name: Validate template |
| 28 | + run: sam validate --lint |
| 29 | + |
| 30 | + - name: Build deployment artifact |
| 31 | + run: sam build |
| 32 | + |
| 33 | + - name: Store artifacts |
| 34 | + uses: ServerlessOpsIO/gha-store-artifacts@v1 |
| 35 | + with: |
| 36 | + use_aws_sam: true |
| 37 | + |
| 38 | + deploy: |
| 39 | + needs: |
| 40 | + - build |
| 41 | + |
| 42 | + environment: production |
| 43 | + runs-on: ubuntu-latest |
| 44 | + permissions: |
| 45 | + id-token: write |
| 46 | + contents: read |
| 47 | + |
| 48 | + steps: |
| 49 | + - name: Setup job workspace |
| 50 | + uses: ServerlessOpsIO/gha-setup-workspace@v1 |
| 51 | + with: |
| 52 | + checkout_artifact: true |
| 53 | + |
| 54 | + - name: Assume AWS credentials |
| 55 | + uses: ServerlessOpsIO/gha-assume-aws-credentials@v1 |
| 56 | + with: |
| 57 | + build_aws_account_id: ${{ secrets.AWS_CICD_ACCOUNT_ID }} |
| 58 | + deploy_aws_account_id: ${{ secrets.DEPLOYMENT_ACCOUNT_ID }} |
| 59 | + |
| 60 | + - name: Deploy via AWS SAM |
| 61 | + uses: ServerlessOpsIO/gha-deploy-aws-sam@v1 |
| 62 | + with: |
| 63 | + aws_account_id: ${{ secrets.DEPLOYMENT_ACCOUNT_ID }} |
| 64 | + env_json: ${{ toJson(env) }} |
| 65 | + vars_json: ${{ toJson(vars) }} |
| 66 | + secrets_json: ${{ toJson(secrets) }} |
0 commit comments