Update ci.yml
Browse files- .github/workflows/ci.yml +82 -27
.github/workflows/ci.yml
CHANGED
@@ -3,37 +3,92 @@ name: CI/CD Pipeline
|
|
3 |
on:
|
4 |
push:
|
5 |
branches:
|
6 |
-
-
|
7 |
- develop
|
8 |
-
-
|
9 |
|
10 |
jobs:
|
11 |
build:
|
12 |
runs-on: ubuntu-latest
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
steps:
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
- name: Push Docker image
|
34 |
-
env:
|
35 |
-
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
|
36 |
-
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
|
37 |
-
run: |
|
38 |
-
echo $DOCKERHUB_PASSWORD | docker login -u $DOCKERHUB_USERNAME --password-stdin
|
39 |
-
docker push yourusername/yourimagename:latest
|
|
|
3 |
on:
|
4 |
push:
|
5 |
branches:
|
6 |
+
- "feature/**"
|
7 |
- develop
|
8 |
+
- main
|
9 |
|
10 |
jobs:
|
11 |
build:
|
12 |
runs-on: ubuntu-latest
|
13 |
+
steps:
|
14 |
+
- name: Checkout Code
|
15 |
+
uses: actions/checkout@v3
|
16 |
+
|
17 |
+
- name: Set up Python
|
18 |
+
uses: actions/setup-python@v3
|
19 |
+
with:
|
20 |
+
python-version: 3.9
|
21 |
+
|
22 |
+
- name: Install Dependencies
|
23 |
+
run: pip install -r requirements.txt
|
24 |
+
|
25 |
+
- name: Run Tests
|
26 |
+
run: python -m unittest discover -s tests || echo "No tests found"
|
27 |
+
|
28 |
+
merge-to-develop:
|
29 |
+
needs: build
|
30 |
+
runs-on: ubuntu-latest
|
31 |
+
if: startsWith(github.ref, 'refs/heads/feature/')
|
32 |
+
steps:
|
33 |
+
- name: Checkout Repository
|
34 |
+
uses: actions/checkout@v3
|
35 |
+
with:
|
36 |
+
fetch-depth: 0
|
37 |
+
|
38 |
+
- name: Set up Git
|
39 |
+
run: |
|
40 |
+
git config --global user.name "GitHub Actions"
|
41 |
+
git config --global user.email "[email protected]"
|
42 |
+
|
43 |
+
- name: Merge Feature Branch into Develop
|
44 |
+
run: |
|
45 |
+
git fetch origin
|
46 |
+
git checkout develop
|
47 |
+
git merge --no-ff ${{ github.ref }}
|
48 |
+
git push origin develop
|
49 |
+
|
50 |
+
merge-to-main:
|
51 |
+
needs: merge-to-develop
|
52 |
+
runs-on: ubuntu-latest
|
53 |
+
if: github.ref == 'refs/heads/develop'
|
54 |
+
steps:
|
55 |
+
- name: Checkout Repository
|
56 |
+
uses: actions/checkout@v3
|
57 |
+
with:
|
58 |
+
fetch-depth: 0
|
59 |
+
|
60 |
+
- name: Set up Git
|
61 |
+
run: |
|
62 |
+
git config --global user.name "GitHub Actions"
|
63 |
+
git config --global user.email "[email protected]"
|
64 |
|
65 |
+
- name: Merge Develop Branch into Main
|
66 |
+
run: |
|
67 |
+
git fetch origin
|
68 |
+
git checkout main
|
69 |
+
git merge --no-ff origin/develop
|
70 |
+
git push origin main
|
71 |
+
|
72 |
+
docker-build:
|
73 |
+
needs: merge-to-main
|
74 |
+
runs-on: ubuntu-latest
|
75 |
+
if: github.ref == 'refs/heads/main'
|
76 |
steps:
|
77 |
+
- name: Checkout Repository
|
78 |
+
uses: actions/checkout@v3
|
79 |
+
|
80 |
+
- name: Set up Docker Buildx
|
81 |
+
uses: docker/setup-buildx-action@v2
|
82 |
+
|
83 |
+
- name: Log in to Docker Hub
|
84 |
+
uses: docker/login-action@v2
|
85 |
+
with:
|
86 |
+
username: ${{ secrets.DOCKER_USERNAME }}
|
87 |
+
password: ${{ secrets.DOCKER_PASSWORD }}
|
88 |
+
|
89 |
+
- name: Build and Push Docker Image
|
90 |
+
uses: docker/build-push-action@v4
|
91 |
+
with:
|
92 |
+
context: .
|
93 |
+
push: true
|
94 |
+
tags: kohlin/nlp-project:latest
|
|
|
|
|
|
|
|
|
|
|
|
|
|