Skip to content

Commit 2c7ed02

Browse files
committed
Add CI
1 parent 3b4637f commit 2c7ed02

File tree

7 files changed

+274
-273
lines changed

7 files changed

+274
-273
lines changed

.github/workflows/SonarQube.yaml

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
1-
# name: SonarCloud for Video Service
2-
# on:
3-
# workflow_call:
4-
# secrets:
5-
# SONAR_TOKEN:
6-
# required: true
7-
# jobs:
8-
# sonar_cloud_scan:
9-
# name: Build and analyze
10-
# runs-on: ubuntu-latest
11-
# steps:
12-
# - uses: actions/checkout@v3
13-
# with:
14-
# fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
15-
# - name: Set up JDK 17
16-
# uses: actions/setup-java@v3
17-
# with:
18-
# java-version: 17
19-
# distribution: 'zulu' # Alternative distribution options are available.
20-
# - name: Cache SonarCloud packages
21-
# uses: actions/cache@v3
22-
# with:
23-
# path: ~/.sonar/cache
24-
# key: ${{ runner.os }}-sonar
25-
# restore-keys: ${{ runner.os }}-sonar
26-
# - name: Cache Maven packages
27-
# uses: actions/cache@v3
28-
# with:
29-
# path: ~/.m2
30-
# key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
31-
# restore-keys: ${{ runner.os }}-m2
32-
# - name: Build and analyze
33-
# env:
34-
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
35-
# run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=DevOps-Video-Sharing_VideoService
1+
name: SonarCloud for Video Service
2+
on:
3+
workflow_call:
4+
secrets:
5+
SONAR_TOKEN:
6+
required: true
7+
jobs:
8+
sonar_cloud_scan:
9+
name: Build and analyze
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v3
13+
with:
14+
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
15+
- name: Set up JDK 17
16+
uses: actions/setup-java@v3
17+
with:
18+
java-version: 17
19+
distribution: 'zulu' # Alternative distribution options are available.
20+
- name: Cache SonarCloud packages
21+
uses: actions/cache@v3
22+
with:
23+
path: ~/.sonar/cache
24+
key: ${{ runner.os }}-sonar
25+
restore-keys: ${{ runner.os }}-sonar
26+
- name: Cache Maven packages
27+
uses: actions/cache@v3
28+
with:
29+
path: ~/.m2
30+
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
31+
restore-keys: ${{ runner.os }}-m2
32+
- name: Build and analyze
33+
env:
34+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
35+
run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=DevOps-Video-Sharing_VideoService

.github/workflows/build-image.yaml

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,37 @@
1-
# name: Build Image Video Service
1+
name: Build Image Video Service
22

3-
# on:
4-
# workflow_call:
5-
# secrets:
6-
# DOCKER_HUB_ACCESS_TOKEN:
7-
# required: true
3+
on:
4+
workflow_call:
5+
secrets:
6+
DOCKER_HUB_ACCESS_TOKEN:
7+
required: true
88

9-
# jobs:
10-
# build-image:
11-
# name: Build and Push Docker Image
12-
# runs-on: ubuntu-latest
13-
# steps:
14-
# - name: Checkout code
15-
# uses: actions/checkout@v3
9+
jobs:
10+
build-image:
11+
name: Build and Push Docker Image
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v3
1616

17-
# - name: Setup JDK 17
18-
# uses: actions/setup-java@v3
19-
# with:
20-
# distribution: 'corretto'
21-
# java-version: 17
17+
- name: Setup JDK 17
18+
uses: actions/setup-java@v3
19+
with:
20+
distribution: 'corretto'
21+
java-version: 17
2222

23-
# - name: Login to Docker Hub
24-
# uses: docker/login-action@v2
25-
# with:
26-
# username: datuits
27-
# password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
23+
- name: Login to Docker Hub
24+
uses: docker/login-action@v2
25+
with:
26+
username: datuits
27+
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
2828

29-
# - name: Build the application
30-
# run: |
31-
# mvn clean
32-
# mvn -B package --file pom.xml
29+
- name: Build the application
30+
run: |
31+
mvn clean
32+
mvn -B package --file pom.xml
3333
34-
# - name: Build and Push the docker image
35-
# run: |
36-
# docker build -t datuits/devops-video-service:latest .
37-
# docker push datuits/devops-video-service:latest
34+
- name: Build and Push the docker image
35+
run: |
36+
docker build -t datuits/devops-video-service:latest .
37+
docker push datuits/devops-video-service:latest
Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,57 @@
1-
# name: Continuous Deployment for Video Service
2-
3-
# on:
4-
# workflow_run:
5-
# workflows: ["Continuous Integration for Video Service"]
6-
# types:
7-
# - completed
8-
9-
# env:
10-
# PROJECT_ID: gke-project-423206
11-
# CLUSTER_NAME: autopilot-cluster-1
12-
# ZONE: us-central1
13-
14-
# jobs:
15-
# deploy:
16-
# name: Deploy to GKE Autopilot
17-
# runs-on: ubuntu-latest
18-
# steps:
19-
# - name: Checkout code
20-
# uses: actions/checkout@v3
21-
22-
# - name: Setup JDK 17
23-
# uses: actions/setup-java@v3
24-
# with:
25-
# distribution: 'corretto'
26-
# java-version: 17
27-
28-
# - name: Build the application
29-
# run: |
30-
# mvn clean
31-
# mvn -B package --file pom.xml
1+
name: Continuous Deployment for Video Service
2+
3+
on:
4+
workflow_run:
5+
workflows: ["Continuous Integration for Video Service"]
6+
types:
7+
- completed
8+
9+
env:
10+
PROJECT_ID: gke-project-423206
11+
CLUSTER_NAME: autopilot-cluster-1
12+
ZONE: us-central1
13+
14+
jobs:
15+
deploy:
16+
name: Deploy to GKE Autopilot
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v3
21+
22+
- name: Setup JDK 17
23+
uses: actions/setup-java@v3
24+
with:
25+
distribution: 'corretto'
26+
java-version: 17
27+
28+
- name: Build the application
29+
run: |
30+
mvn clean
31+
mvn -B package --file pom.xml
3232
33-
# - name: Authenticate
34-
# uses: google-github-actions/auth@v2
35-
# with:
36-
# credentials_json: ${{ secrets.GCP_SA_KEY }}
33+
- name: Authenticate
34+
uses: google-github-actions/auth@v2
35+
with:
36+
credentials_json: ${{ secrets.GCP_SA_KEY }}
3737

38-
# - name: Configure gcloud
39-
# uses: google-github-actions/setup-gcloud@v2
40-
# with:
41-
# project_id: ${{ env.PROJECT_ID }}
42-
# install_components: 'gke-gcloud-auth-plugin'
38+
- name: Configure gcloud
39+
uses: google-github-actions/setup-gcloud@v2
40+
with:
41+
project_id: ${{ env.PROJECT_ID }}
42+
install_components: 'gke-gcloud-auth-plugin'
4343

4444

45-
# - name: Set cluster context
46-
# run: |
47-
# gcloud container clusters get-credentials ${{ env.CLUSTER_NAME }} --zone ${{ env.ZONE }} --project ${{ env.PROJECT_ID }}
45+
- name: Set cluster context
46+
run: |
47+
gcloud container clusters get-credentials ${{ env.CLUSTER_NAME }} --zone ${{ env.ZONE }} --project ${{ env.PROJECT_ID }}
4848
49-
# - name: Apply Kubernetes manifests
50-
# run: |
51-
# kubectl apply -f resources.yaml
49+
- name: Apply Kubernetes manifests
50+
run: |
51+
kubectl apply -f resources.yaml
5252
53-
# notifications:
54-
# needs: deploy
55-
# uses: ./.github/workflows/notifyCD.yaml
56-
# secrets:
57-
# SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL}}
53+
notifications:
54+
needs: deploy
55+
uses: ./.github/workflows/notifyCD.yaml
56+
secrets:
57+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL}}

.github/workflows/main.yaml

Lines changed: 49 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,50 @@
1-
# name: Continuous Integration for Video Service
2-
3-
# on:
4-
# push:
5-
# branches:
6-
# - main
7-
8-
# jobs:
9-
# testing:
10-
# name: Testing Video Service
11-
# runs-on: ubuntu-latest
12-
# steps:
13-
14-
# - name: Checkout code
15-
# uses: actions/checkout@v3
16-
17-
# - name: Setup JDK 17
18-
# uses: actions/setup-java@v3
19-
# with:
20-
# distribution: 'corretto'
21-
# java-version: 17
22-
23-
# - name: Set up MongoDB URI
24-
# run: echo "SPRING_DATA_MONGODB_URI=mongodb://localhost:27017/video-service" >> $GITHUB_ENV
25-
26-
# - name: Unit Tests
27-
# run: mvn -B test --file pom.xml
28-
29-
# sonar_cloud_scan:
30-
# needs: testing
31-
# uses: ./.github/workflows/SonarQube.yaml
32-
# secrets:
33-
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
1+
name: Continuous Integration for Video Service
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- master
8+
9+
jobs:
10+
testing:
11+
name: Testing Video Service
12+
runs-on: ubuntu-latest
13+
steps:
14+
15+
- name: Checkout code
16+
uses: actions/checkout@v3
17+
18+
- name: Setup JDK 17
19+
uses: actions/setup-java@v3
20+
with:
21+
distribution: 'corretto'
22+
java-version: 17
23+
24+
- name: Set up MongoDB URI
25+
run: echo "SPRING_DATA_MONGODB_URI=mongodb://localhost:27017/video-service" >> $GITHUB_ENV
26+
27+
- name: Unit Tests
28+
run: mvn -B test --file pom.xml
29+
30+
# sonar_cloud_scan:
31+
# needs: testing
32+
# uses: ./.github/workflows/SonarQube.yaml
33+
# secrets:
34+
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
3435

35-
# build-image:
36-
# needs: testing
37-
# uses: ./.github/workflows/build-image.yaml
38-
# secrets:
39-
# DOCKER_HUB_ACCESS_TOKEN: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
40-
41-
# scan-image:
42-
# needs: build-image
43-
# uses: ./.github/workflows/scan-image.yaml
44-
45-
# notify:
46-
# needs: scan-image
47-
# uses: ./.github/workflows/notifyCI.yaml
48-
# secrets:
49-
# SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
36+
build-image:
37+
needs: testing
38+
uses: ./.github/workflows/build-image.yaml
39+
secrets:
40+
DOCKER_HUB_ACCESS_TOKEN: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
41+
42+
# scan-image:
43+
# needs: build-image
44+
# uses: ./.github/workflows/scan-image.yaml
45+
46+
# notify:
47+
# needs: scan-image
48+
# uses: ./.github/workflows/notifyCI.yaml
49+
# secrets:
50+
# SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

0 commit comments

Comments
 (0)