refactor: trigger github action on pull_request to main branch #7
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 to AWS | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
build-and-deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '20' | |
- name: Install dependencies | |
run: | | |
cd ./app | |
npm install | |
cd ../ | |
cd ./infrastructure | |
npm install | |
- name: Build Gatsby app | |
run: | | |
cd ./app | |
npm run build | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{secrets.AWS_ACCESS_KEY_ID}} | |
aws-secret-access-key: ${{secrets.AWS_SECRET_ACCESS_KEY}} | |
aws-region: eu-central-1 | |
- name: Deploy by AWS CDK | |
run: | | |
cd ./infrastructure | |
npm install -g aws-cdk | |
npm run build | |
cdk bootstrap --require-approval never | |
cdk synth --require-approval never | |
cdk deploy --require-approval never |