Skip to content

Commit

Permalink
Add CD pipeline to ci-cd.yml to deploy to AWS S3
Browse files Browse the repository at this point in the history
  • Loading branch information
DrCBeatz committed Oct 27, 2024
1 parent 5e709e0 commit dce0d54
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 38 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# .github/workflows/ci-cd.yml
name: CI/CD

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
build-and-test:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [18.x]

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: "npm"

- name: Install dependencies
run: npm ci

- name: Run tests
run: npm test

deploy:
needs: build-and-test
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' # Deploy only from the main branch

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}

- name: Sync files to S3
uses: aws-actions/s3-sync@v2
with:
source-dir: src
destination-bucket: ${{ secrets.AWS_S3_BUCKET_NAME }}
delete: true
38 changes: 0 additions & 38 deletions .github/workflows/ci.yml

This file was deleted.

0 comments on commit dce0d54

Please sign in to comment.