Add GitHub Actions workflow for CloudFormation deployment #17
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: Deploy MediaLake | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
workflow_dispatch: | |
env: | |
AWS_REGION: us-east-1 | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
permissions: | |
id-token: write | |
contents: read | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.11' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install aws-cdk-lib constructs | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/GitHubActionsRole | |
aws-region: ${{ env.AWS_REGION }} | |
- name: Create config file if not exists | |
run: | | |
if [ -f guidance-for-medialake-on-aws/config.json ]; then | |
echo "Config file already exists" | |
else | |
echo "Creating config file" | |
cp .cicd/template/config.json-template guidance-for-medialake-on-aws/config.json | |
# Update the config with environment-specific values | |
sed -i 's/"region": "us-east-1"/"region": "${{ env.AWS_REGION }}"/' guidance-for-medialake-on-aws/config.json | |
sed -i 's/"account": "123456789012"/"account": "${{ secrets.AWS_ACCOUNT_ID }}"/' guidance-for-medialake-on-aws/config.json | |
fi | |
- name: CDK Bootstrap (if needed) | |
run: | | |
cd guidance-for-medialake-on-aws | |
npx cdk bootstrap | |
- name: CDK Deploy | |
run: | | |
cd guidance-for-medialake-on-aws | |
npx cdk deploy --all --require-approval never | |
- name: Run tests | |
run: | | |
cd guidance-for-medialake-on-aws | |
python -m pytest tests/ -v |