Deploy AWS SAM Resources (Reusable) #5
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: Deploy AWS SAM Resources | |
on: | |
workflow_dispatch: | |
inputs: | |
region: | |
description: 'AWS Region' | |
required: true | |
default: 'us-east-1' | |
environment: | |
type: choice | |
options: | |
- dev | |
- prd | |
description: 'Environment (dev or prd)' | |
required: true | |
default: 'dev' | |
env: | |
AWS_REGION: us-east-1 | |
AWS_CICD_ROLE_ARN: arn:aws:iam::796019718156:role/splayshapi-cicd-Role-I6ZfsEHvFThf | |
AWS_CICD_BUCKET: ${{ github.organization }}-${{ github.repository }}-deployment-bucket | |
jobs: | |
stack: | |
name: Deploy stack to AWS | |
runs-on: ubuntu-latest | |
permissions: | |
id-token: write | |
contents: read | |
outputs: | |
env-name: ${{ steps.env-name.outputs.environment }} | |
steps: | |
- name: Configure AWS credentials | |
id: creds | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
role-to-assume: ${{ env.AWS_CICD_ROLE_ARN }} | |
aws-region: ${{ env.AWS_REGION }} | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Configure environment name | |
id: env-name | |
env: | |
REPO: ${{ github.repository }} | |
run: | | |
ENVIRONMENT=`echo $REPO-${{ github.event.inputs.environment }} | tr "/" "-" ` | |
echo "Environment name: $ENVIRONMENT" | |
echo "environment=$ENVIRONMENT" >> $GITHUB_OUTPUT | |
- name: Setup Python | |
uses: actions/setup-python@v2 | |
- name: Setup SAM | |
uses: aws-actions/setup-sam@v1 | |
# sam build | |
- name: SAM Build | |
run: sam build --use-container | |
# sam deploy | |
- name: SAM Deploy | |
run: | | |
sam deploy \ | |
--no-confirm-changeset \ | |
--no-fail-on-empty-changeset \ | |
--stack-name "${{ steps.env-name.outputs.environment }}" \ | |
--s3-bucket "$AWS_CICD_BUCKET" \ | |
--capabilities CAPABILITY_IAM \ | |
--region "$AWS_REGION" | |
# - name: Deploy splayshapi aws resources | |
# id: splayshapi | |
# uses: aws-actions/aws-cloudformation-github-deploy@master | |
# with: | |
# name: ${{ steps.env-name.outputs.environment }}-splayshapi | |
# template: "file:///infra/sam-pipeline.yml" | |
# no-fail-on-empty-changeset: "1" |