Skip to content

Commit

Permalink
Merge branch 'main' of github.com:Adoptaunpeludo/backend
Browse files Browse the repository at this point in the history
  • Loading branch information
JoseAlbDR committed Feb 15, 2024
2 parents 80dab8e + f7469b9 commit 1996f73
Showing 1 changed file with 22 additions and 24 deletions.
46 changes: 22 additions & 24 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,8 @@ on:
env:
DOCKER_USER: ${{ secrets.DOCKER_USER }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}

jobs:

# test:
# name: Jest Tests
# runs-on: ubuntu-latest

# steps:
# - name: Checkout code
# uses: actions/checkout@v3

# - name: Set up NodeJS
# uses: actions/setup-node@v1
# with:
# node-version: 20

# - name: Install all dependencies
# run: npm install

# - name: Run Tests
# run: npm test

build:
runs-on: ubuntu-latest

Expand All @@ -40,6 +20,14 @@ jobs:
with:
fetch-depth: 0

- name: Git Semantic Version
uses: PaulHatch/semantic-version@v5.4.0
with:
major_pattern: "major:"
minor_pattern: "feat:"
version_format: "${major}.${minor}.${patch}-prerelease${increment}"
id: version

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

Expand All @@ -49,6 +37,16 @@ jobs:
username: ${{ env.DOCKER_USER }}
password: ${{ env.DOCKER_PASSWORD }}

- name: Build and push Docker Image
uses: docker/build-push-action@v2
env:
NEW_VERSION: ${{ steps.version.outputs.version }}
with:
context: ./
push: true
dockerfile: ./Dockerfile
tags: jaderodev/aup-backend:${{ env.NEW_VERSION }}

- name: Build and push Docker Image
uses: docker/build-push-action@v2
with:
Expand Down Expand Up @@ -77,15 +75,15 @@ jobs:
- name: Move to project folder
run: |
ssh -o StrictHostKeyChecking=no -i key.pem ubuntu@3.82.157.13 'cd backend/ && sudo docker compose down'
ssh -o StrictHostKeyChecking=no -i key.pem ubuntu@3.228.164.55 'cd backend/ && sudo docker compose down'
- name: Remove old image
run: |
ssh -o StrictHostKeyChecking=no -i key.pem ubuntu@3.82.157.13 'sudo docker image rm -f backend-aup-backend:latest'
ssh -o StrictHostKeyChecking=no -i key.pem ubuntu@3.228.164.55 'sudo docker image rm -f backend-aup-backend:latest'
- name: Run new containers
run: |
ssh -o StrictHostKeyChecking=no -i key.pem ubuntu@3.82.157.13 'cd backend/ && git pull && sudo docker compose up -d'
ssh -o StrictHostKeyChecking=no -i key.pem ubuntu@3.228.164.55 'cd backend/ && git pull && sudo docker compose up -d'


0 comments on commit 1996f73

Please sign in to comment.