Skip to content
This repository was archived by the owner on May 30, 2024. It is now read-only.

Commit e4c40f8

Browse files
author
Noah Lee
authored
Combine dev and production environment for the pipeline (#426)
* Add the serialization option * Combine dev and prod environment for the pipeline
1 parent 744c198 commit e4c40f8

File tree

5 files changed

+96
-77
lines changed

5 files changed

+96
-77
lines changed

.github/workflows/deploy-to-cloud.yaml

Lines changed: 11 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -4,49 +4,30 @@ on:
44
deployment
55

66
jobs:
7-
deploy-local:
7+
deploy:
88
runs-on: ubuntu-latest
9-
if: ${{ github.event.deployment.environment == 'local' }}
109
steps:
11-
-
12-
name: Checkout
13-
uses: actions/checkout@v2
14-
1510
-
16-
name: Deploy successfully
17-
if: success()
1811
uses: chrnorm/deployment-status@releases/v1
1912
with:
2013
deployment_id: ${{ github.event.deployment.id }}
21-
state: "success"
14+
description: Trigger the pipeline
15+
state: "queued"
2216
token: "${{ github.token }}"
23-
description: Finish to deploy successfully.
24-
25-
deploy-dev:
26-
runs-on: ubuntu-latest
27-
# https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#deployment
28-
if: ${{ github.event.deployment.environment == 'dev' }}
29-
steps:
3017
-
3118
name: Checkout
3219
uses: actions/checkout@v2
3320
-
34-
name: Create values.yaml
35-
uses: finnp/create-file-action@master
36-
env:
37-
FILE_NAME: "./.github/values.yaml"
38-
FILE_BASE64: "aW5ncmVzczoKICBlbmFibGVkOiB0cnVlCiAgYW5ub3RhdGlvbnM6CiAgICBrdWJlcm5ldGVzLmlvL2luZ3Jlc3MuY2xhc3M6IG5naW54CiAgICBjZXJ0LW1hbmFnZXIuaW8vY2x1c3Rlci1pc3N1ZXI6ICJsZXRzZW5jcnlwdC1wcm9kIgogIGhvc3RzOgogICAgLSBob3N0OiBkZXYuZ2l0cGxveS5pbwogICAgICBwYXRoczoKICAgICAgICAtIHBhdGg6IC8KICAgICAgICAgIHBhdGhUeXBlOiBQcmVmaXgKICB0bHM6CiAgIC0gc2VjcmV0TmFtZTogZ2l0cGxveS1kZXYtdGxzCiAgICAgaG9zdHM6CiAgICAgICAtIGRldi5naXRwbG95LmlvCgpyZXNvdXJjZXM6CiAgcmVxdWVzdHM6CiAgICBjcHU6IDUwbQogICAgbWVtb3J5OiAxMjhNaQoKZW52OgogIEdJVFBMT1lfREVCVUdfTU9ERTogInRydWUiCiAgR0lUUExPWV9TRVJWRVJfSE9TVDogImRldi5naXRwbG95LmlvIgogIEdJVFBMT1lfU0VSVkVSX1BST1RPOiBodHRwcwogIEdJVFBMT1lfQURNSU5fVVNFUlM6ICJoYW5qdW5sZWUiCiAgR0lUUExPWV9NRU1CRVJfRU5UUklFUzogImdpdHBsb3ktaW8iCiAgR0lUUExPWV9QUk9NRVRIRVVTX0VOQUJMRUQ6ICJ0cnVlIgoKZXh0cmFTZWNyZXROYW1lc0ZvckVudkZyb206CiAgLSBnaXRwbG95LWRldi1zZWNyZXQKCnBlcnNpc3RlbnRWb2x1bWU6CiAgZW5hYmxlZDogdHJ1ZQo="
39-
-
40-
name: Start to deploy
4121
uses: chrnorm/deployment-status@releases/v1
4222
with:
4323
deployment_id: ${{ github.event.deployment.id }}
4424
description: Start to deploy to the Kubernetes
4525
state: "in_progress"
4626
token: "${{ github.token }}"
4727
-
48-
name: Deploy
28+
name: Deploy Dev
4929
uses: WyriHaximus/github-action-helm3@v2
30+
if: ${{ github.event.deployment.environment == 'dev' }}
5031
with:
5132
# Upgrade to the version.
5233
exec: >
@@ -55,55 +36,15 @@ jobs:
5536
--install
5637
--atomic
5738
--namespace=gitploy
58-
-f .github/values.yaml
39+
-f release/values.dev.yaml
5940
--set=image.tag=${GITHUB_REF#refs/tags/v}
60-
--set=image.pullPolicy=Always
41+
--set=image.pullPolicy=${{ github.event.deployment.payload.pullPolicy }}
6142
--description="Upgrade to ${GITHUB_REF#refs/tags/}"
6243
kubeconfig: '${{ secrets.KUBECONFIG }}'
6344
-
64-
name: Deploy successfully
65-
if: success()
66-
uses: chrnorm/deployment-status@releases/v1
67-
with:
68-
deployment_id: ${{ github.event.deployment.id }}
69-
description: Finish to deploy successfully.
70-
state: "success"
71-
token: "${{ github.token }}"
72-
-
73-
name: Deploy failed
74-
if: failure()
75-
uses: chrnorm/deployment-status@releases/v1
76-
with:
77-
deployment_id: ${{ github.event.deployment.id }}
78-
description: Failed to deploy.
79-
state: "failure"
80-
token: "${{ github.token }}"
81-
82-
deploy-production:
83-
runs-on: ubuntu-latest
84-
# https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#deployment
85-
if: ${{ github.event.deployment.environment == 'production' }}
86-
steps:
87-
-
88-
name: Checkout
89-
uses: actions/checkout@v2
90-
-
91-
name: Create values.yaml
92-
uses: finnp/create-file-action@master
93-
env:
94-
FILE_NAME: "./.github/values.yaml"
95-
FILE_BASE64: "cmVwbGljYUNvdW50OiAyCgppbmdyZXNzOgogIGVuYWJsZWQ6IHRydWUKICBhbm5vdGF0aW9uczoKICAgIGt1YmVybmV0ZXMuaW8vaW5ncmVzcy5jbGFzczogbmdpbngKICAgIGNlcnQtbWFuYWdlci5pby9jbHVzdGVyLWlzc3VlcjogImxldHNlbmNyeXB0LXByb2QiCiAgaG9zdHM6CiAgICAtIGhvc3Q6IGNsb3VkLmdpdHBsb3kuaW8KICAgICAgcGF0aHM6CiAgICAgICAgLSBwYXRoOiAvCiAgICAgICAgICBwYXRoVHlwZTogUHJlZml4CiAgdGxzOgogICAtIHNlY3JldE5hbWU6IGdpdHBsb3ktcHJvZC10bHMKICAgICBob3N0czoKICAgICAgIC0gY2xvdWQuZ2l0cGxveS5pbwoKcmVzb3VyY2VzOgogIHJlcXVlc3RzOgogICAgY3B1OiAxMDBtCiAgICBtZW1vcnk6IDI1Nk1pCgplbnY6CiAgR0lUUExPWV9ERUJVR19NT0RFOiAidHJ1ZSIKICBHSVRQTE9ZX1NFUlZFUl9IT1NUOiAiY2xvdWQuZ2l0cGxveS5pbyIKICBHSVRQTE9ZX1NFUlZFUl9QUk9UTzogaHR0cHMKICBHSVRQTE9ZX0FETUlOX1VTRVJTOiAiaGFuanVubGVlIgogIEdJVFBMT1lfR0lUSFVCX1NDT1BFUzogInB1YmxpY19yZXBvLHJlYWQ6dXNlcixyZWFkOm9yZyIKICBHSVRQTE9ZX1NUT1JFX0RSSVZFUjogIm15c3FsIgoKZXh0cmFTZWNyZXROYW1lc0ZvckVudkZyb206CiAgLSBnaXRwbG95LXByb2Qtc2VjcmV0Cg=="
96-
-
97-
name: Start to deploy
98-
uses: chrnorm/deployment-status@releases/v1
99-
with:
100-
deployment_id: ${{ github.event.deployment.id }}
101-
description: Start to deploy to the Kubernetes
102-
state: "in_progress"
103-
token: "${{ github.token }}"
104-
-
105-
name: Deploy
45+
name: Deploy Production
10646
uses: WyriHaximus/github-action-helm3@v2
47+
if: ${{ github.event.deployment.environment == 'production' }}
10748
with:
10849
# Upgrade to the version.
10950
exec: >
@@ -112,13 +53,12 @@ jobs:
11253
--install
11354
--atomic
11455
--namespace=gitploy
115-
-f .github/values.yaml
56+
-f release/values.production.yaml
11657
--set=image.tag=${GITHUB_REF#refs/tags/v}
117-
--set=image.pullPolicy=Always
58+
--set=image.pullPolicy=${{ github.event.deployment.payload.pullPolicy }}
11859
--description="Upgrade to ${GITHUB_REF#refs/tags/}"
11960
kubeconfig: '${{ secrets.KUBECONFIG }}'
12061
-
121-
name: Deploy successfully
12262
if: success()
12363
uses: chrnorm/deployment-status@releases/v1
12464
with:
@@ -127,7 +67,6 @@ jobs:
12767
state: "success"
12868
token: "${{ github.token }}"
12969
-
130-
name: Deploy failed
13170
if: failure()
13271
uses: chrnorm/deployment-status@releases/v1
13372
with:

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,3 @@
1616
# vendor/
1717
.env
1818
*.db
19-
20-
release/

deploy.yml

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
envs:
22
- name: dev
33
task: ${GITPLOY_DEPLOY_TASK:=rollback}:kubernetes
4-
# Disable "auto_merge" to avoid merge conflict
5-
# when it deploys the tag behind the head.
64
auto_merge: false
7-
# Check test and publish is succeed.
85
required_contexts:
96
- "publish-image"
107
deployable_ref: 'v.*\..*\..*'
8+
serialization: true
9+
inputs:
10+
pullPolicy:
11+
required: true
12+
type: select
13+
description: Image pull policy
14+
options:
15+
- Always
16+
- IfNotPresent
17+
default: Always
1118

1219
- name: production
1320
task: ${GITPLOY_DEPLOY_TASK:=rollback}:kubernetes
@@ -21,3 +28,13 @@ envs:
2128
- hanjunlee
2229
- gitploy-qa
2330
deployable_ref: 'v.*\..*\..*'
31+
serialization: true
32+
inputs:
33+
pullPolicy:
34+
required: true
35+
type: select
36+
description: Image pull policy
37+
options:
38+
- Always
39+
- IfNotPresent
40+
default: Always

release/values.dev.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
ingress:
2+
enabled: true
3+
annotations:
4+
kubernetes.io/ingress.class: nginx
5+
cert-manager.io/cluster-issuer: "letsencrypt-prod"
6+
hosts:
7+
- host: dev.gitploy.io
8+
paths:
9+
- path: /
10+
pathType: Prefix
11+
tls:
12+
- secretName: gitploy-dev-tls
13+
hosts:
14+
- dev.gitploy.io
15+
16+
resources:
17+
requests:
18+
cpu: 50m
19+
memory: 128Mi
20+
21+
env:
22+
GITPLOY_DEBUG_MODE: "true"
23+
GITPLOY_SERVER_HOST: "dev.gitploy.io"
24+
GITPLOY_SERVER_PROTO: https
25+
GITPLOY_ADMIN_USERS: "hanjunlee"
26+
GITPLOY_MEMBER_ENTRIES: "gitploy-io"
27+
GITPLOY_PROMETHEUS_ENABLED: "true"
28+
29+
extraSecretNamesForEnvFrom:
30+
- gitploy-dev-secret
31+
32+
persistentVolume:
33+
enabled: true

release/values.production.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
replicaCount: 2
2+
3+
ingress:
4+
enabled: true
5+
annotations:
6+
kubernetes.io/ingress.class: nginx
7+
cert-manager.io/cluster-issuer: "letsencrypt-prod"
8+
hosts:
9+
- host: cloud.gitploy.io
10+
paths:
11+
- path: /
12+
pathType: Prefix
13+
tls:
14+
- secretName: gitploy-prod-tls
15+
hosts:
16+
- cloud.gitploy.io
17+
18+
resources:
19+
requests:
20+
cpu: 100m
21+
memory: 256Mi
22+
23+
env:
24+
GITPLOY_DEBUG_MODE: "true"
25+
GITPLOY_SERVER_HOST: "cloud.gitploy.io"
26+
GITPLOY_SERVER_PROTO: https
27+
GITPLOY_ADMIN_USERS: "hanjunlee"
28+
GITPLOY_GITHUB_SCOPES: "public_repo,read:user,read:org"
29+
GITPLOY_STORE_DRIVER: "mysql"
30+
31+
extraSecretNamesForEnvFrom:
32+
- gitploy-prod-secret

0 commit comments

Comments
 (0)