kohlin commited on
Commit
fff33b7
·
1 Parent(s): 64bf4bd

Update ci.yml

Browse files
Files changed (1) hide show
  1. .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
- - main
7
  - develop
8
- - feature/ci-setup
9
 
10
  jobs:
11
  build:
12
  runs-on: ubuntu-latest
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
 
 
 
 
 
 
 
 
 
 
 
 
14
  steps:
15
- - name: Checkout code
16
- uses: actions/checkout@v2
17
-
18
- - name: Set up Python
19
- uses: actions/setup-python@v2
20
- with:
21
- python-version: '3.8'
22
-
23
- - name: Install dependencies
24
- run: |
25
- pip install --upgrade pip
26
- pip install -r requirements.txt
27
- python -m spacy download en_core_web_sm
28
-
29
- - name: Build Docker image
30
- run: |
31
- docker build -t kohlin/nlp-spacy:latest .
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