Improve CI/CD

This commit is contained in:
Shkar T. Noori 2022-10-25 16:14:46 +00:00
parent 45aae70dee
commit 0d8ca48856
No known key found for this signature in database
GPG Key ID: E7AD76088FB6FE02
5 changed files with 52 additions and 130 deletions

View File

@ -14,8 +14,7 @@ on:
required: true
secrets:
KUBECONFIG:
required: true
KUBECONFIG: { required: true }
env:
NAMESPACE: dit-docs
@ -30,7 +29,7 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Kubectl tool installer
uses: Azure/setup-kubectl@v1
@ -42,8 +41,6 @@ jobs:
- name: Setup Kustomize
uses: imranismail/setup-kustomize@v1
with:
kustomize-version: "4.4.1"
- name: Edit kustomization file
working-directory: kubernetes/base

View File

@ -1,64 +1,42 @@
---
name: Deploy To Development
on:
push:
branches:
- dev
paths-ignore:
- "README.md"
- ".vscode/**"
- ".github/**"
- "!.github/workflows/tests-base.yaml"
- "!.github/workflows/deploy-base.yaml"
- "!.github/workflows/deploy-dev.yaml"
concurrency:
group: deploy-dev
cancel-in-progress: true
jobs:
setup:
name: Setup
runs-on: ubuntu-20.04
env:
IMAGE: "reg.dev.krd/dit-docs/dsm-client:${{ github.ref_name }}"
steps:
- name: Extract image name
run: echo "Using image name $IMAGE"
outputs:
image: ${{ env.IMAGE }}
image-sha: ${{ env.IMAGE }}-${{ github.sha }}
test:
uses: ditkrg/dit-digital-service-manual/.github/workflows/tests-base.yaml@dev
uses: ./.github/workflows/tests-base.yaml
build-push:
name: Build and Push
needs: [setup, test]
runs-on: ubuntu-20.04
timeout-minutes: 10
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to Registry
uses: docker/login-action@v1
with:
registry: reg.dev.krd
username: ${{ secrets.HARBOR_PUBLIC_USER }}
password: ${{ secrets.HARBOR_PUBLIC_TOKEN }}
- name: Build and push Docker images
uses: docker/build-push-action@v2
with:
push: true
tags: |-
${{ needs.setup.outputs.image }}
${{ needs.setup.outputs.image-sha }}
cache-from: type=registry,ref=${{ needs.setup.outputs.image }}
cache-to: type=inline
build:
uses: ditkrg/build-image-workflow/.github/workflows/workflow.yaml@v1
needs: test
with:
image: dit-docs/dsm-client
secrets:
username: ${{ secrets.HARBOR_PUBLIC_USER }}
password: ${{ secrets.HARBOR_PUBLIC_TOKEN }}
deploy:
uses: ditkrg/dit-digital-service-manual/.github/workflows/deploy-base.yaml@dev
needs: [setup, build-push]
uses: ./.github/workflows/deploy-base.yaml
needs: build
with:
image: ${{ needs.setup.outputs.image-sha }}
image: ${{ needs.build.outputs.tag }}
env_url: https://service-manual.docs.dev.krd
env_name: development

View File

@ -1,64 +1,42 @@
---
name: Deploy To Production
on:
push:
branches:
- main
paths-ignore:
- "README.md"
- ".vscode/**"
- ".github/**"
- "!.github/workflows/tests-base.yaml"
- "!.github/workflows/deploy-base.yaml"
- "!.github/workflows/deploy-production.yaml"
concurrency:
group: deploy-production
cancel-in-progress: true
cancel-in-progress: false
jobs:
setup:
name: Setup
runs-on: ubuntu-20.04
env:
IMAGE: "reg.dev.krd/dit-docs/dsm-client:${{ github.ref_name }}"
steps:
- name: Extract image name
run: echo "Using image name $IMAGE"
outputs:
image: ${{ env.IMAGE }}
image-sha: ${{ env.IMAGE }}-${{ github.sha }}
test:
uses: ditkrg/dit-digital-service-manual/.github/workflows/tests-base.yaml@main
build-push:
name: Build and Push
needs: [setup, test]
runs-on: ubuntu-20.04
timeout-minutes: 10
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to Registry
uses: docker/login-action@v1
with:
registry: reg.dev.krd
username: ${{ secrets.HARBOR_PUBLIC_USER }}
password: ${{ secrets.HARBOR_PUBLIC_TOKEN }}
- name: Build and push Docker images
uses: docker/build-push-action@v2
with:
push: true
tags: |-
${{ needs.setup.outputs.image }}
${{ needs.setup.outputs.image-sha }}
cache-from: type=registry,ref=${{ needs.setup.outputs.image }}
cache-to: type=inline
build:
uses: ditkrg/build-image-workflow/.github/workflows/workflow.yaml@v1
needs: test
with:
image: dit-docs/dsm-client
secrets:
username: ${{ secrets.HARBOR_PUBLIC_USER }}
password: ${{ secrets.HARBOR_PUBLIC_TOKEN }}
deploy:
uses: ditkrg/dit-digital-service-manual/.github/workflows/deploy-base.yaml@main
needs: [setup, build-push]
uses: ./.github/workflows/deploy-base.yaml
needs: build
with:
image: ${{ needs.setup.outputs.image-sha }}
image: ${{ needs.build.outputs.tag }}
env_url: https://docs.digital.gov.krd
env_name: production

View File

@ -1,6 +1,16 @@
---
name: Run Tests
on:
push:
branches-ignore:
- dev
- main
paths-ignore:
- "README.md"
- ".vscode/**"
workflow_call:
jobs:
@ -11,15 +21,13 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Kubectl tool installer
uses: Azure/setup-kubectl@v1
- name: Setup Kustomize
uses: imranismail/setup-kustomize@v1
with:
kustomize-version: "4.4.1"
- name: Build k8s manifests
working-directory: kubernetes
@ -27,6 +35,6 @@ jobs:
envs=( "development" "production" )
for i in "${envs[@]}"
do
do
kustomize build "$i"
done

View File

@ -1,39 +0,0 @@
name: Run Tests
on:
push:
branches-ignore:
- dev
- staging
- main
paths-ignore:
- "README.md"
- ".vscode/**"
jobs:
run-tests:
name: Run Tests
timeout-minutes: 10
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Kubectl tool installer
uses: Azure/setup-kubectl@v1
- name: Setup Kustomize
uses: imranismail/setup-kustomize@v1
with:
kustomize-version: "4.4.1"
- name: Build k8s manifests
working-directory: kubernetes
run: |
envs=( "development" "production" )
for i in "${envs[@]}"
do
kustomize build "$i"
done