Skip to content

Commit

Permalink
Update CD
Browse files Browse the repository at this point in the history
  • Loading branch information
khoitmp committed Aug 1, 2024
1 parent dab035d commit c055be9
Show file tree
Hide file tree
Showing 7 changed files with 90 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: service
name: service (build)

on:
push:
Expand All @@ -17,7 +17,7 @@ jobs:

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

- name: Restore
run: dotnet restore
Expand Down Expand Up @@ -51,7 +51,7 @@ jobs:
path: ./tests/reports/code-coverage.xml

- name: Login Docker Hub
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
Expand Down
24 changes: 24 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: service (deploy)

on:
workflow_run:
workflows: ["service (build)"]
types:
- completed
workflow_dispatch:

jobs:
build:
runs-on: self-hosted

environment: Default

steps:
- name: Configure kubectl
run: echo "${{ secrets.KUBECONFIG }}" | base64 --decode > $HOME/.kube/config

- name: Deploy with Helm
run: |
helm upgrade --install service ./helm-chart \
--set image.repository=khoitmp/service \
--set image.tag=latest
23 changes: 23 additions & 0 deletions helm-chart/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
4 changes: 4 additions & 0 deletions helm-chart/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: v2
name: helm-chart
description: A Helm chart for Kubernetes
version: 0.1.0
19 changes: 19 additions & 0 deletions helm-chart/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Release.Name }}
spec:
replicas: {{ .Values.deployment.scale }}
selector:
matchLabels:
app: {{ .Release.Name }}
template:
metadata:
labels:
app: {{ .Release.Name }}
spec:
containers:
- name: {{ .Release.Name }}
image: {{ .Values.deployment.image.repository }}/{{ .Values.deployment.image.name }}:{{ .Values.deployment.image.tag }}
ports:
- containerPort: 80
10 changes: 10 additions & 0 deletions helm-chart/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v1
kind: Service
metadata:
name: {{ .Release.Name }}
spec:
type: ClusterIP
ports:
- port: 80
selector:
app: {{ .Release.Name }}
7 changes: 7 additions & 0 deletions helm-chart/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
deployment:
name: service
scale: 3
image:
name: service
tag: latest
repository: khoitmp

0 comments on commit c055be9

Please sign in to comment.