Merge pull request #1 from Hyrozdmr/hayri #3
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: Build and Deploy | |
on: | |
push: | |
branches: ['main'] | |
pull_request: | |
branches: ['main'] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [22.x] | |
mongodb-version: ['6.0'] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install dependencies | |
run: npm install | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node-version }} | |
cache: 'npm' | |
- name: Start MongoDB | |
uses: supercharge/[email protected] | |
with: | |
mongodb-version: ${{ matrix.mongodb-version }} | |
- name: Cypress run | |
uses: cypress-io/github-action@v6 | |
with: | |
start: npm run start:test | |
wait-on: http://localhost:3030 | |
deploy: | |
needs: build # Fixed indentation here | |
if: github.ref == 'refs/heads/main' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install dependencies | |
run: npm ci | |
- name: Configure AWS Credentials | |
uses: aws-actions/configure-aws-credentials@v2 | |
with: | |
aws-s3-bucket: ${{ secrets.AWS_BUCKET_NAME }} | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: eu-west-2 | |
- name: Create deployment package | |
run: zip -r deploy.zip . -x '*.git*' 'node_modules/*' | |
- name: Upload deployment package to S3 | |
run: aws s3 cp deploy.zip s3://${{ secrets.AWS_BUCKET_NAME }}/deploy.zip | |
# - name: Deploy to S3 | |
# run: | | |
# aws s3 sync . s3://${{ secrets.AWS_BUCKET_NAME }} --exclude ".git/*" --exclude "node_modules/*" --delete | |
- name: Create CodeDeploy Deployment | |
run: | | |
aws deploy create-deployment \ | |
--application-name cavalieri-acebook \ | |
--deployment-group-name cavalieri-acebook-codeDeploy \ | |
--s3-location bucket=${{ secrets.AWS_BUCKET_NAME }},bundleType=zip,key=deploy.zip \ | |
--file-exists-behavior OVERWRITE | |