Merge pull request #1 from qchen-dev/feature #9
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 Frontend | |
| on: | |
| push: | |
| branches: ['main'] | |
| jobs: | |
| docker-test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Build Docker image for testing (using Dockerfile.dev) | |
| 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: | |
| runs-on: ubuntu-latest | |
| needs: docker-test # Ensures tests run before deploy | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Build Docker image for deployment (using Dockerfile) | |
| run: docker build -t cygnetops/react-prod -f Dockerfile . | |
| - name: Generate deploy package (zip) | |
| run: zip -r deploy.zip . -x '*.git*' | |
| - 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 |