Skip to content

Commit

Permalink
simplify backend cicd workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Zafei-Erin committed May 3, 2024
1 parent f3e46ed commit c6993cf
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 57 deletions.
66 changes: 34 additions & 32 deletions .github/workflows/Backend-cd.yml
Original file line number Diff line number Diff line change
@@ -1,38 +1,40 @@
name: Backend-cd
# CD is removed from AWS to vercel

on:
workflow_run:
workflows: ['Backend-ci']
types: [completed]
branches: [main]
pull_request:
types: [labeled]
# name: Backend-cd

jobs:
deploy-git:
runs-on: ubuntu-latest
# on:
# workflow_run:
# workflows: ['Backend-ci']
# types: [completed]
# branches: [main]
# pull_request:
# types: [labeled]

steps:
- name: Checkout
uses: actions/checkout@v4
# jobs:
# deploy-git:
# runs-on: ubuntu-latest

- name: Remove deploy label
uses: actions-ecosystem/action-remove-labels@v1
with:
labels: "prod: backend"
# steps:
# - name: Checkout
# uses: actions/checkout@v4

deploy-aws:
needs: deploy-git
runs-on: aws-nft
# - name: Remove deploy label
# uses: actions-ecosystem/action-remove-labels@v1
# with:
# labels: "prod: backend"

steps:
- name: stop old image
run: sudo docker-compose stop
- name: remove old image
run: sudo docker-compose rm -f
- name: pull new image
run: sudo docker-compose pull
- name: run new image
run: sudo docker-compose up -d
- name: prune images
run: sudo docker image prune -af
# deploy-aws:
# needs: deploy-git
# runs-on: aws-nft

# steps:
# - name: stop old image
# run: sudo docker-compose stop
# - name: remove old image
# run: sudo docker-compose rm -f
# - name: pull new image
# run: sudo docker-compose pull
# - name: run new image
# run: sudo docker-compose up -d
# - name: prune images
# run: sudo docker image prune -af
46 changes: 23 additions & 23 deletions .github/workflows/Backend-ci .yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ name: Backend-ci
on:
push:
branches: [main]
paths: "backend/**"
paths: ["backend/**"]
pull_request:
types: [opened, synchronize, reopened]
paths: "backend/**"
paths: ["backend/**"]

jobs:
git-ci:
Expand Down Expand Up @@ -36,29 +36,29 @@ jobs:
run: npm ci
working-directory: "backend"

docker-push:
needs: git-ci
runs-on: ubuntu-latest
# docker-push:
# needs: git-ci
# runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
# steps:
# - name: Checkout
# uses: actions/checkout@v4

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# - name: Login to Docker Hub
# uses: docker/login-action@v3
# with:
# username: ${{ secrets.DOCKERHUB_USERNAME }}
# password: ${{ secrets.DOCKERHUB_TOKEN }}

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

- name: print location
run: pwd
# - name: print location
# run: pwd

- name: Build and push
uses: docker/build-push-action@v5
with:
context: ./backend
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/nft-mkp-api:latest
# - name: Build and push
# uses: docker/build-push-action@v5
# with:
# context: ./backend
# push: true
# tags: ${{ secrets.DOCKERHUB_USERNAME }}/nft-mkp-api:latest
4 changes: 2 additions & 2 deletions .github/workflows/Frontend-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ name: Frontend-ci
on:
push:
branches: [main]
paths: 'frontend/**'
paths: ['frontend/**']
pull_request:
types: [opened, synchronize, reopened]
paths: 'frontend/**'
paths: ['frontend/**']

jobs:
git-ci:
Expand Down

0 comments on commit c6993cf

Please sign in to comment.