reverted back to default app.js #96
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: Node.js CI | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
build: | |
name: Build and Test Backend | |
runs-on: ubuntu-latest | |
steps: | |
# Step 1: Checkout the code | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # Full-depth clone for SonarQube analysis | |
# Step 2: Set up Node.js environment (latest version) | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "22.x" | |
cache: npm | |
# Step 3: Install dependencies | |
- name: Install Dependencies | |
run: npm ci | |
# Step 4: Build the source code (if applicable) | |
- name: Build Source Code | |
run: npm run build --if-present | |
# Step 5: Run tests | |
- name: Run Tests | |
run: npm test --if-present | |
lint: | |
name: Lint Backend | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
# Step 1: Checkout the code | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # Full-depth clone for SonarQube analysis | |
# Step 2: Run Snyk Security Scan using Snyk's cloud service | |
- name: Snyk Security Scan | |
uses: snyk/actions/node@master | |
with: | |
command: test --all-projects | |
env: | |
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} | |
# Step 3: SonarQube Scan | |
- name: SonarQube Scan | |
uses: sonarsource/sonarqube-scan-action@master | |
env: | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} | |
deliver: | |
name: Deliver Backend | |
needs: lint | |
runs-on: ubuntu-latest | |
steps: | |
# Step 1: Checkout the code | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
# Step 2: Log in to Docker Hub | |
- name: Log in to Docker Hub | |
run: echo "${{ secrets.DOCKER_HUB_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_HUB_USERNAME }}" --password-stdin | |
# Step 3: Build Docker image | |
- name: Build Docker Image | |
run: docker build -t gregory789/contint-backend-repository:contint-backend-image . | |
# Step 4: Push Docker image to Docker Hub | |
- name: Push Docker Image | |
run: docker push gregory789/contint-backend-repository:contint-backend-image | |
deploy: | |
name: Deploy Backend | |
needs: deliver | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Executing remote SSH commands using SSH key | |
uses: appleboy/ssh-action@v1.0.3 | |
with: | |
host: 34.193.142.100 | |
username: ubuntu | |
key: ${{ secrets.SSH_KEY }} | |
port: 22 | |
script: sudo /home/ubuntu/deploy.sh |