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

Commit

Permalink
Combine dev and production environment for the pipeline (#426)
Browse files Browse the repository at this point in the history
* Add the serialization option

* Combine dev and prod environment for the pipeline
  • Loading branch information
Noah Lee authored May 2, 2022
1 parent 744c198 commit e4c40f8
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 77 deletions.
83 changes: 11 additions & 72 deletions .github/workflows/deploy-to-cloud.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,49 +4,30 @@ on:
deployment

jobs:
deploy-local:
deploy:
runs-on: ubuntu-latest
if: ${{ github.event.deployment.environment == 'local' }}
steps:
-
name: Checkout
uses: actions/checkout@v2

-
name: Deploy successfully
if: success()
uses: chrnorm/deployment-status@releases/v1
with:
deployment_id: ${{ github.event.deployment.id }}
state: "success"
description: Trigger the pipeline
state: "queued"
token: "${{ github.token }}"
description: Finish to deploy successfully.

deploy-dev:
runs-on: ubuntu-latest
# https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#deployment
if: ${{ github.event.deployment.environment == 'dev' }}
steps:
-
name: Checkout
uses: actions/checkout@v2
-
name: Create values.yaml
uses: finnp/create-file-action@master
env:
FILE_NAME: "./.github/values.yaml"
FILE_BASE64: "aW5ncmVzczoKICBlbmFibGVkOiB0cnVlCiAgYW5ub3RhdGlvbnM6CiAgICBrdWJlcm5ldGVzLmlvL2luZ3Jlc3MuY2xhc3M6IG5naW54CiAgICBjZXJ0LW1hbmFnZXIuaW8vY2x1c3Rlci1pc3N1ZXI6ICJsZXRzZW5jcnlwdC1wcm9kIgogIGhvc3RzOgogICAgLSBob3N0OiBkZXYuZ2l0cGxveS5pbwogICAgICBwYXRoczoKICAgICAgICAtIHBhdGg6IC8KICAgICAgICAgIHBhdGhUeXBlOiBQcmVmaXgKICB0bHM6CiAgIC0gc2VjcmV0TmFtZTogZ2l0cGxveS1kZXYtdGxzCiAgICAgaG9zdHM6CiAgICAgICAtIGRldi5naXRwbG95LmlvCgpyZXNvdXJjZXM6CiAgcmVxdWVzdHM6CiAgICBjcHU6IDUwbQogICAgbWVtb3J5OiAxMjhNaQoKZW52OgogIEdJVFBMT1lfREVCVUdfTU9ERTogInRydWUiCiAgR0lUUExPWV9TRVJWRVJfSE9TVDogImRldi5naXRwbG95LmlvIgogIEdJVFBMT1lfU0VSVkVSX1BST1RPOiBodHRwcwogIEdJVFBMT1lfQURNSU5fVVNFUlM6ICJoYW5qdW5sZWUiCiAgR0lUUExPWV9NRU1CRVJfRU5UUklFUzogImdpdHBsb3ktaW8iCiAgR0lUUExPWV9QUk9NRVRIRVVTX0VOQUJMRUQ6ICJ0cnVlIgoKZXh0cmFTZWNyZXROYW1lc0ZvckVudkZyb206CiAgLSBnaXRwbG95LWRldi1zZWNyZXQKCnBlcnNpc3RlbnRWb2x1bWU6CiAgZW5hYmxlZDogdHJ1ZQo="
-
name: Start to deploy
uses: chrnorm/deployment-status@releases/v1
with:
deployment_id: ${{ github.event.deployment.id }}
description: Start to deploy to the Kubernetes
state: "in_progress"
token: "${{ github.token }}"
-
name: Deploy
name: Deploy Dev
uses: WyriHaximus/github-action-helm3@v2
if: ${{ github.event.deployment.environment == 'dev' }}
with:
# Upgrade to the version.
exec: >
Expand All @@ -55,55 +36,15 @@ jobs:
--install
--atomic
--namespace=gitploy
-f .github/values.yaml
-f release/values.dev.yaml
--set=image.tag=${GITHUB_REF#refs/tags/v}
--set=image.pullPolicy=Always
--set=image.pullPolicy=${{ github.event.deployment.payload.pullPolicy }}
--description="Upgrade to ${GITHUB_REF#refs/tags/}"
kubeconfig: '${{ secrets.KUBECONFIG }}'
-
name: Deploy successfully
if: success()
uses: chrnorm/deployment-status@releases/v1
with:
deployment_id: ${{ github.event.deployment.id }}
description: Finish to deploy successfully.
state: "success"
token: "${{ github.token }}"
-
name: Deploy failed
if: failure()
uses: chrnorm/deployment-status@releases/v1
with:
deployment_id: ${{ github.event.deployment.id }}
description: Failed to deploy.
state: "failure"
token: "${{ github.token }}"

deploy-production:
runs-on: ubuntu-latest
# https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#deployment
if: ${{ github.event.deployment.environment == 'production' }}
steps:
-
name: Checkout
uses: actions/checkout@v2
-
name: Create values.yaml
uses: finnp/create-file-action@master
env:
FILE_NAME: "./.github/values.yaml"
FILE_BASE64: "cmVwbGljYUNvdW50OiAyCgppbmdyZXNzOgogIGVuYWJsZWQ6IHRydWUKICBhbm5vdGF0aW9uczoKICAgIGt1YmVybmV0ZXMuaW8vaW5ncmVzcy5jbGFzczogbmdpbngKICAgIGNlcnQtbWFuYWdlci5pby9jbHVzdGVyLWlzc3VlcjogImxldHNlbmNyeXB0LXByb2QiCiAgaG9zdHM6CiAgICAtIGhvc3Q6IGNsb3VkLmdpdHBsb3kuaW8KICAgICAgcGF0aHM6CiAgICAgICAgLSBwYXRoOiAvCiAgICAgICAgICBwYXRoVHlwZTogUHJlZml4CiAgdGxzOgogICAtIHNlY3JldE5hbWU6IGdpdHBsb3ktcHJvZC10bHMKICAgICBob3N0czoKICAgICAgIC0gY2xvdWQuZ2l0cGxveS5pbwoKcmVzb3VyY2VzOgogIHJlcXVlc3RzOgogICAgY3B1OiAxMDBtCiAgICBtZW1vcnk6IDI1Nk1pCgplbnY6CiAgR0lUUExPWV9ERUJVR19NT0RFOiAidHJ1ZSIKICBHSVRQTE9ZX1NFUlZFUl9IT1NUOiAiY2xvdWQuZ2l0cGxveS5pbyIKICBHSVRQTE9ZX1NFUlZFUl9QUk9UTzogaHR0cHMKICBHSVRQTE9ZX0FETUlOX1VTRVJTOiAiaGFuanVubGVlIgogIEdJVFBMT1lfR0lUSFVCX1NDT1BFUzogInB1YmxpY19yZXBvLHJlYWQ6dXNlcixyZWFkOm9yZyIKICBHSVRQTE9ZX1NUT1JFX0RSSVZFUjogIm15c3FsIgoKZXh0cmFTZWNyZXROYW1lc0ZvckVudkZyb206CiAgLSBnaXRwbG95LXByb2Qtc2VjcmV0Cg=="
-
name: Start to deploy
uses: chrnorm/deployment-status@releases/v1
with:
deployment_id: ${{ github.event.deployment.id }}
description: Start to deploy to the Kubernetes
state: "in_progress"
token: "${{ github.token }}"
-
name: Deploy
name: Deploy Production
uses: WyriHaximus/github-action-helm3@v2
if: ${{ github.event.deployment.environment == 'production' }}
with:
# Upgrade to the version.
exec: >
Expand All @@ -112,13 +53,12 @@ jobs:
--install
--atomic
--namespace=gitploy
-f .github/values.yaml
-f release/values.production.yaml
--set=image.tag=${GITHUB_REF#refs/tags/v}
--set=image.pullPolicy=Always
--set=image.pullPolicy=${{ github.event.deployment.payload.pullPolicy }}
--description="Upgrade to ${GITHUB_REF#refs/tags/}"
kubeconfig: '${{ secrets.KUBECONFIG }}'
-
name: Deploy successfully
if: success()
uses: chrnorm/deployment-status@releases/v1
with:
Expand All @@ -127,7 +67,6 @@ jobs:
state: "success"
token: "${{ github.token }}"
-
name: Deploy failed
if: failure()
uses: chrnorm/deployment-status@releases/v1
with:
Expand Down
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,3 @@
# vendor/
.env
*.db

release/
23 changes: 20 additions & 3 deletions deploy.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
envs:
- name: dev
task: ${GITPLOY_DEPLOY_TASK:=rollback}:kubernetes
# Disable "auto_merge" to avoid merge conflict
# when it deploys the tag behind the head.
auto_merge: false
# Check test and publish is succeed.
required_contexts:
- "publish-image"
deployable_ref: 'v.*\..*\..*'
serialization: true
inputs:
pullPolicy:
required: true
type: select
description: Image pull policy
options:
- Always
- IfNotPresent
default: Always

- name: production
task: ${GITPLOY_DEPLOY_TASK:=rollback}:kubernetes
Expand All @@ -21,3 +28,13 @@ envs:
- hanjunlee
- gitploy-qa
deployable_ref: 'v.*\..*\..*'
serialization: true
inputs:
pullPolicy:
required: true
type: select
description: Image pull policy
options:
- Always
- IfNotPresent
default: Always
33 changes: 33 additions & 0 deletions release/values.dev.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
ingress:
enabled: true
annotations:
kubernetes.io/ingress.class: nginx
cert-manager.io/cluster-issuer: "letsencrypt-prod"
hosts:
- host: dev.gitploy.io
paths:
- path: /
pathType: Prefix
tls:
- secretName: gitploy-dev-tls
hosts:
- dev.gitploy.io

resources:
requests:
cpu: 50m
memory: 128Mi

env:
GITPLOY_DEBUG_MODE: "true"
GITPLOY_SERVER_HOST: "dev.gitploy.io"
GITPLOY_SERVER_PROTO: https
GITPLOY_ADMIN_USERS: "hanjunlee"
GITPLOY_MEMBER_ENTRIES: "gitploy-io"
GITPLOY_PROMETHEUS_ENABLED: "true"

extraSecretNamesForEnvFrom:
- gitploy-dev-secret

persistentVolume:
enabled: true
32 changes: 32 additions & 0 deletions release/values.production.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
replicaCount: 2

ingress:
enabled: true
annotations:
kubernetes.io/ingress.class: nginx
cert-manager.io/cluster-issuer: "letsencrypt-prod"
hosts:
- host: cloud.gitploy.io
paths:
- path: /
pathType: Prefix
tls:
- secretName: gitploy-prod-tls
hosts:
- cloud.gitploy.io

resources:
requests:
cpu: 100m
memory: 256Mi

env:
GITPLOY_DEBUG_MODE: "true"
GITPLOY_SERVER_HOST: "cloud.gitploy.io"
GITPLOY_SERVER_PROTO: https
GITPLOY_ADMIN_USERS: "hanjunlee"
GITPLOY_GITHUB_SCOPES: "public_repo,read:user,read:org"
GITPLOY_STORE_DRIVER: "mysql"

extraSecretNamesForEnvFrom:
- gitploy-prod-secret

0 comments on commit e4c40f8

Please sign in to comment.