Merge pull request #104 from whyphi/staging #197
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: Chalice Deployment | |
on: | |
push: | |
branches: | |
- main | |
- staging | |
- dev | |
jobs: | |
deployment-prod: | |
name: deploy-prod | |
runs-on: ubuntu-latest | |
# if: contains(' | |
# refs/heads/staging | |
# refs/heads/main | |
# ', github.ref) | |
if: (github.ref == 'refs/heads/main') | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Setup Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.9' | |
cache: 'pip' # caching pip dependencies | |
# Configure AWS Credential | |
- name: Configure AWS Credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: ${{ secrets.AWS_DEFAULT_REGION }} | |
- run: pip install pipenv | |
- run: pipenv requirements > requirements.txt | |
- run: pip install -r requirements.txt | |
- name: Package chalice application | |
run: chalice package /tmp/packaged-app/ --stage prod | |
- name: Upload deployment file to S3 bucket | |
run: aws cloudformation package --template-file /tmp/packaged-app/sam.json --s3-bucket zap-deployment --output-template-file /tmp/packaged-app/packaged.yaml | |
- name: Deploy app using Cloudformation | |
run: aws cloudformation deploy --template-file /tmp/packaged-app/packaged.yaml --stack-name zap-stack-prod --capabilities CAPABILITY_IAM --s3-bucket zap-deployment | |
deployment-dev: | |
name: deploy-dev | |
runs-on: ubuntu-latest | |
# if: startsWith(github.ref, 'refs/heads/dev') | |
if: (github.ref == 'refs/heads/staging') | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Setup Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.9' | |
cache: 'pip' # caching pip dependencies | |
# Configure AWS Credential | |
- name: Configure AWS Credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: ${{ secrets.AWS_DEFAULT_REGION }} | |
- run: pip install pipenv | |
- run: pipenv requirements > requirements.txt | |
- run: pip install -r requirements.txt | |
- name: Package chalice application | |
run: chalice package /tmp/packaged-app/ | |
- name: Upload deployment file to S3 bucket | |
run: aws cloudformation package --template-file /tmp/packaged-app/sam.json --s3-bucket zap-deployment --output-template-file /tmp/packaged-app/packaged.yaml | |
- name: Deploy app using Cloudformation | |
run: aws cloudformation deploy --template-file /tmp/packaged-app/packaged.yaml --stack-name zap-stack-dev --capabilities CAPABILITY_IAM --s3-bucket zap-deployment |