Skip to content

add deploy step to Elastic Beanstalk #5

add deploy step to Elastic Beanstalk

add deploy step to Elastic Beanstalk #5

Workflow file for this run

name: Deploy Frontend
on:
push:
branches: ['main']
pull_request:
branches: ['main']
jobs:
docker-test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Build Docker image for testing
run: docker build -t cygnetops/react-test -f Dockerfile.dev .
- name: Run tests in Docker container
run: docker run -e CI=true cygnetops/react-test npm test
deploy:
needs: docker-test
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '22.x'
- name: Install dependencies
run: npm ci
- name: Build the app
run: npm run build --if-present
- name: Clean up node_modules (optional)
run: rm -rf node_modules
- name: Generate deploy package (zip)
run: |
zip -r deploy.zip . \
-x "*.git*" \
"node_modules/*" \
".github/*" \
"*.test.js" \
"*.md"
- name: Deploy to Elastic Beanstalk
uses: einaregilsson/beanstalk-deploy@v18
with:
aws_access_key: ${{ secrets.AWS_ACCESS_KEY }}
aws_secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
application_name: frontend
environment_name: Frontend-env
existing_bucket_name: elasticbeanstalk-ap-southeast-2-376578549272
region: ap-southeast-2
version_label: ${{ github.sha }}
deployment_package: deploy.zip