Skip to content

Commit

Permalink
checkout different branch for each job 5
Browse files Browse the repository at this point in the history
  • Loading branch information
norali12 committed Sep 18, 2024
1 parent ef3aa3d commit efbee22
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 23 deletions.
39 changes: 16 additions & 23 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ jobs:
with:
ref: CI-CD-pipline

- name: Switch to Backend Branch
run: |
git fetch origin
git checkout main-backend
# - name: Switch to Backend Branch
# run: |
# git fetch origin
# git checkout main-backend

- name: Log in to Docker Hub
uses: docker/login-action@v3
Expand All @@ -27,16 +27,19 @@ jobs:
password: ${{ secrets.DOCKER_ACCESS_TOKEN}}

- name: Extract the latest Git tag
run: echo "TAG=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV
run: |
echo "TAG=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV
echo $TAG
- name: Build and Push Backend Image
uses: docker/build-push-action@v6
with:
push: true
tags: noraali/backend:${{ env.TAG }}
context: . #./backend
context: . #./backend
file: ./Dockerfile #./backend/Dockerfile


# build-frontend:
# runs-on: ubuntu-latest

Expand All @@ -49,7 +52,7 @@ jobs:
# - name: Switch to frontend Branch
# run: |
# git fetch origin
# git checkout main-frontend
# git checkout main-frontend

# - name: Log in to Docker Hub
# uses: docker/login-action@v3
Expand All @@ -58,7 +61,7 @@ jobs:
# password: ${{ secrets.DOCKER_ACCESS_TOKEN}}

# - name: Extract the latest Git tag
# run: echo "TAG=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV
# run: echo "TAG=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV

# - name: Build and Push frontend Image
# uses: docker/build-push-action@v6
Expand All @@ -67,21 +70,11 @@ jobs:
# tags: noraali/frontend:${{ env.TAG }}
# context: . #./frontend
# file: ./Dockerfile #./frontend/Dockerfile







# branches:
# - CI-CD-pipline
# - main-backend
# - main-frontend



# if: github.ref == 'refs/heads/CI-CD-pipline'
# main-backend
# - CI-CD-pipline
# - main-backend
# - main-frontend

# if: github.ref == 'refs/heads/CI-CD-pipline'
# main-backend

36 changes: 36 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: CI/CD Pipeline

on:
push:
# branches:
# - CI-CD-pipline
# - main-backend
# - main-frontend
tags:
- v*

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

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

- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_ACCESS_TOKEN}}

- name: Extract the latest Git tag
run: echo "TAG=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV

- name: Build and Push Backend Image
# if: github.ref == 'refs/heads/CI-CD-pipline' main-backend
uses: docker/build-push-action@v6
with:
push: true
tags: noraali/backend:${{ env.TAG }}
context: .
file: ./Dockerfile

0 comments on commit efbee22

Please sign in to comment.