Update README.md #24
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: CI/CD Pipeline | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
env: | |
AWS_REGION: ${{ secrets.AWS_REGION }} | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Set up Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: '20' # Specify your Node.js version | |
- name: Debug Print working directory | |
run: pwd | |
- name: Debug List files | |
run: ls -al | |
- name: Install backend dependencies | |
run: | | |
cd cdk | |
npm install | |
- name: Synthesize CDK | |
run: | | |
cd cdk | |
export FRONTEND_STACK_EXPORTS_AVAILABLE=false | |
npx cdk synth | |
- name: Deploy BackendStack | |
run: | | |
cd cdk | |
npx cdk deploy BackendStack --require-approval never | |
- name: Get API Gateway URL | |
id: get-url | |
run: | | |
api_url=$(aws cloudformation list-exports --query "Exports[?Name=='ApiGateway'].Value" --output text) | |
echo "API_URL=${api_url}" >> $GITHUB_ENV | |
echo "REACT_APP_API_GATEWAY_URL=${api_url}" > frontend/.env | |
- name: Print .env file contents | |
run: | | |
cd frontend | |
cat .env | |
- name: Install frontend dependencies | |
run: | | |
cd frontend | |
npm install | |
- name: Build frontend | |
run: | | |
cd frontend | |
export BUILD_PATH=../cdk/resources/build | |
npx react-scripts build | |
- name: Deploy FrontendStack | |
run: | | |
cd cdk | |
npx cdk deploy FrontendStack --require-approval never | |
- name: Deploy BackendStack with exports available | |
run: | | |
cd cdk | |
export FRONTEND_STACK_EXPORTS_AVAILABLE=true | |
npx cdk deploy BackendStack --require-approval never | |
- name: Get DeploymentURL | |
id: get-deployment-url | |
run: | | |
deployment_url=$(aws cloudformation list-exports --query "Exports[?Name=='CloudfrontURL'].Value" --output text) | |
echo "Access the deployment at: ${deployment_url}" |