Skip to content

Commit a16d15f

Browse files
committed
Update CI and ENV
1 parent 868e6a3 commit a16d15f

File tree

6 files changed

+182
-182
lines changed

6 files changed

+182
-182
lines changed

.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
REACT_APP_API_URL=http://192.168.120.131:32020
1+
REACT_APP_API_URL=http://192.168.120.131:31122

.github/workflows/deployCD.yaml

Lines changed: 55 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,58 @@
1-
# name: Continuous Deployment for Frontend
2-
3-
# on:
4-
# workflow_run:
5-
# workflows: ["Continuous Integration for Frontend"]
6-
# types:
7-
# - completed
8-
# env:
9-
# PROJECT_ID: gke-project-423206
10-
# CLUSTER_NAME: autopilot-cluster-1
11-
# ZONE: us-central1
1+
name: Continuous Deployment for Frontend
2+
3+
on:
4+
workflow_run:
5+
workflows: ["Continuous Integration for Frontend"]
6+
types:
7+
- completed
8+
env:
9+
PROJECT_ID: gke-project-423206
10+
CLUSTER_NAME: autopilot-cluster-1
11+
ZONE: us-central1
1212

1313

14-
# jobs:
15-
# deploy:
16-
# name: Deploy to GKE Autopilot
17-
# runs-on: ubuntu-latest
18-
19-
# strategy:
20-
# matrix:
21-
# node-version: [18.x]
22-
23-
# steps:
24-
# - name: Checkout code
25-
# uses: actions/checkout@v3
26-
27-
# - name: Build the application
28-
# run: |
29-
# npm ci
30-
# npm run build
31-
# env:
32-
# CI: ""
33-
34-
# - name: Authenticate
35-
# uses: google-github-actions/auth@v2
36-
# with:
37-
# credentials_json: '${{ secrets.GCP_SA_KEY }}'
38-
39-
# - name: Configure gcloud SDK
40-
# uses: google-github-actions/setup-gcloud@v2
41-
# with:
42-
# project_id: ${{ env.PROJECT_ID }}
43-
# install_components: 'gke-gcloud-auth-plugin'
44-
45-
46-
# - name: Set cluster context
47-
# run: |
48-
# gcloud container clusters get-credentials ${{ env.CLUSTER_NAME }} --zone ${{ env.ZONE }} --project ${{ env.PROJECT_ID }}
49-
50-
# - name: Apply Kubernetes manifests
51-
# run: |
52-
# kubectl apply -f resources.yaml
14+
jobs:
15+
deploy:
16+
name: Deploy to GKE Autopilot
17+
runs-on: ubuntu-latest
18+
19+
strategy:
20+
matrix:
21+
node-version: [18.x]
22+
23+
steps:
24+
- name: Checkout code
25+
uses: actions/checkout@v3
26+
27+
- name: Build the application
28+
run: |
29+
npm ci
30+
npm run build
31+
env:
32+
CI: ""
33+
34+
- name: Authenticate
35+
uses: google-github-actions/auth@v2
36+
with:
37+
credentials_json: '${{ secrets.GCP_SA_KEY }}'
38+
39+
- name: Configure gcloud SDK
40+
uses: google-github-actions/setup-gcloud@v2
41+
with:
42+
project_id: ${{ env.PROJECT_ID }}
43+
install_components: 'gke-gcloud-auth-plugin'
44+
45+
46+
- name: Set cluster context
47+
run: |
48+
gcloud container clusters get-credentials ${{ env.CLUSTER_NAME }} --zone ${{ env.ZONE }} --project ${{ env.PROJECT_ID }}
49+
50+
- name: Apply Kubernetes manifests
51+
run: |
52+
kubectl apply -f resources.yaml
5353
54-
# notifications:
55-
# needs: deploy
56-
# uses: ./.github/workflows/notifyCD.yaml
57-
# secrets:
58-
# SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
54+
notifications:
55+
needs: deploy
56+
uses: ./.github/workflows/notifyCD.yaml
57+
secrets:
58+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

.github/workflows/notifyCD.yaml

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,36 @@
1-
# name: Send Slack Notification for Frontend
1+
name: Send Slack Notification for Frontend
22

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

9-
# jobs:
10-
# success_notifier:
11-
# if: success()
12-
# runs-on: ubuntu-latest
13-
# steps:
14-
# - name: Send success notification on Slack
15-
# uses: slackapi/[email protected]
16-
# with:
17-
# payload: |
18-
# {
19-
# "text": "The Continuous Deployment for Frontend workflow has completed successfully."
20-
# }
21-
# env:
22-
# SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
9+
jobs:
10+
success_notifier:
11+
if: success()
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Send success notification on Slack
15+
uses: slackapi/[email protected]
16+
with:
17+
payload: |
18+
{
19+
"text": "The Continuous Deployment for Frontend workflow has completed successfully."
20+
}
21+
env:
22+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
2323

24-
# failure_notifier:
25-
# if: failure()
26-
# runs-on: ubuntu-latest
27-
# steps:
28-
# - name: Send failure notification on Slack
29-
# uses: slackapi/[email protected]
30-
# with:
31-
# payload: |
32-
# {
33-
# "text": "The Continuous Deployment for Frontend workflow has failed."
34-
# }
35-
# env:
36-
# SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
24+
failure_notifier:
25+
if: failure()
26+
runs-on: ubuntu-latest
27+
steps:
28+
- name: Send failure notification on Slack
29+
uses: slackapi/[email protected]
30+
with:
31+
payload: |
32+
{
33+
"text": "The Continuous Deployment for Frontend workflow has failed."
34+
}
35+
env:
36+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

.github/workflows/notifyCI.yaml

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,36 @@
1-
# name: Send Slack Notification for Frontend
1+
name: Send Slack Notification for Frontend
22

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

9-
# jobs:
10-
# success_notifier:
11-
# if: success()
12-
# runs-on: ubuntu-latest
13-
# steps:
14-
# - name: Send success notification on Slack
15-
# uses: slackapi/[email protected]
16-
# with:
17-
# payload: |
18-
# {
19-
# "text": "The Continuous Integration for Frontend workflow has completed successfully."
20-
# }
21-
# env:
22-
# SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
9+
jobs:
10+
success_notifier:
11+
if: success()
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Send success notification on Slack
15+
uses: slackapi/[email protected]
16+
with:
17+
payload: |
18+
{
19+
"text": "The Continuous Integration for Frontend workflow has completed successfully."
20+
}
21+
env:
22+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
2323

24-
# failure_notifier:
25-
# if: failure()
26-
# runs-on: ubuntu-latest
27-
# steps:
28-
# - name: Send failure notification on Slack
29-
# uses: slackapi/[email protected]
30-
# with:
31-
# payload: |
32-
# {
33-
# "text": "The Continuous Integration for Frontend workflow has failed."
34-
# }
35-
# env:
36-
# SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
24+
failure_notifier:
25+
if: failure()
26+
runs-on: ubuntu-latest
27+
steps:
28+
- name: Send failure notification on Slack
29+
uses: slackapi/[email protected]
30+
with:
31+
payload: |
32+
{
33+
"text": "The Continuous Integration for Frontend workflow has failed."
34+
}
35+
env:
36+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

.github/workflows/scan-image.yaml

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,47 @@
1-
# name: Scan Image Frontend
2-
# on:
3-
# workflow_call:
1+
name: Scan Image Frontend
2+
on:
3+
workflow_call:
44

5-
# jobs:
6-
# scan-image:
7-
# name: Security Scan
8-
# runs-on: ubuntu-latest
9-
# steps:
10-
# - name: Install Trivy
11-
# run: |
12-
# sudo apt-get update
13-
# sudo apt-get install -y wget
14-
# wget https://github.com/aquasecurity/trivy/releases/download/v0.40.0/trivy_0.40.0_Linux-64bit.deb
15-
# sudo dpkg -i trivy_0.40.0_Linux-64bit.deb
5+
jobs:
6+
scan-image:
7+
name: Security Scan
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Install Trivy
11+
run: |
12+
sudo apt-get update
13+
sudo apt-get install -y wget
14+
wget https://github.com/aquasecurity/trivy/releases/download/v0.40.0/trivy_0.40.0_Linux-64bit.deb
15+
sudo dpkg -i trivy_0.40.0_Linux-64bit.deb
1616
17-
# - name: Scan Docker image with Trivy
18-
# id: scan-image
19-
# run: |
20-
# trivy image --format json --output scan-results.json datuits/devops-frontend:latest
17+
- name: Scan Docker image with Trivy
18+
id: scan-image
19+
run: |
20+
trivy image --format json --output scan-results.json datuits/devops-frontend:latest
2121
22-
# - name: Extract high and critical vulnerabilities
23-
# id: extract_vulnerabilities
24-
# run: |
25-
# jq -r '
26-
# def hr(severity):
27-
# if severity == "HIGH" or severity == "CRITICAL" then true else false end;
28-
# def to_md:
29-
# "| " + (.VulnerabilityID // "") + " | " + (.PkgName // "") + " | " + (.InstalledVersion // "") + " | " + (.Severity // "") + " | " + (.Title // "") + " |";
30-
# [
31-
# "# Docker Image Scan Results",
32-
# "",
33-
# "## High and Critical Vulnerabilities",
34-
# "",
35-
# "| Vulnerability ID | Package | Version | Severity | Description |",
36-
# "|------------------|---------|---------|----------|-------------|",
37-
# (.Results[] | .Vulnerabilities[] | select(hr(.Severity)) | to_md),
38-
# ""
39-
# ] | join("\n")
40-
# ' scan-results.json > vulnerability-report.md
22+
- name: Extract high and critical vulnerabilities
23+
id: extract_vulnerabilities
24+
run: |
25+
jq -r '
26+
def hr(severity):
27+
if severity == "HIGH" or severity == "CRITICAL" then true else false end;
28+
def to_md:
29+
"| " + (.VulnerabilityID // "") + " | " + (.PkgName // "") + " | " + (.InstalledVersion // "") + " | " + (.Severity // "") + " | " + (.Title // "") + " |";
30+
[
31+
"# Docker Image Scan Results",
32+
"",
33+
"## High and Critical Vulnerabilities",
34+
"",
35+
"| Vulnerability ID | Package | Version | Severity | Description |",
36+
"|------------------|---------|---------|----------|-------------|",
37+
(.Results[] | .Vulnerabilities[] | select(hr(.Severity)) | to_md),
38+
""
39+
] | join("\n")
40+
' scan-results.json > vulnerability-report.md
4141
42-
# - name: Upload vulnerability report
43-
# uses: actions/upload-artifact@v2
44-
# with:
45-
# name: vulnerability-report
46-
# path: vulnerability-report.md
42+
- name: Upload vulnerability report
43+
uses: actions/upload-artifact@v2
44+
with:
45+
name: vulnerability-report
46+
path: vulnerability-report.md
4747

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
# name: SonarCloud for Frontend
2-
# on:
3-
# workflow_call:
4-
# secrets:
5-
# SONAR_TOKEN:
6-
# required: true
7-
# jobs:
8-
# sonarcloud-scan:
9-
# name: SonarCloud
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: SonarCloud Scan
16-
# uses: SonarSource/sonarcloud-github-action@master
17-
# env:
18-
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
1+
name: SonarCloud for Frontend
2+
on:
3+
workflow_call:
4+
secrets:
5+
SONAR_TOKEN:
6+
required: true
7+
jobs:
8+
sonarcloud-scan:
9+
name: SonarCloud
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: SonarCloud Scan
16+
uses: SonarSource/sonarcloud-github-action@master
17+
env:
18+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

0 commit comments

Comments
 (0)