Improve CI/CD
This commit is contained in:
parent
45aae70dee
commit
0d8ca48856
7
.github/workflows/deploy-base.yaml
vendored
7
.github/workflows/deploy-base.yaml
vendored
@ -14,8 +14,7 @@ on:
|
|||||||
required: true
|
required: true
|
||||||
|
|
||||||
secrets:
|
secrets:
|
||||||
KUBECONFIG:
|
KUBECONFIG: { required: true }
|
||||||
required: true
|
|
||||||
|
|
||||||
env:
|
env:
|
||||||
NAMESPACE: dit-docs
|
NAMESPACE: dit-docs
|
||||||
@ -30,7 +29,7 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Kubectl tool installer
|
- name: Kubectl tool installer
|
||||||
uses: Azure/setup-kubectl@v1
|
uses: Azure/setup-kubectl@v1
|
||||||
@ -42,8 +41,6 @@ jobs:
|
|||||||
|
|
||||||
- name: Setup Kustomize
|
- name: Setup Kustomize
|
||||||
uses: imranismail/setup-kustomize@v1
|
uses: imranismail/setup-kustomize@v1
|
||||||
with:
|
|
||||||
kustomize-version: "4.4.1"
|
|
||||||
|
|
||||||
- name: Edit kustomization file
|
- name: Edit kustomization file
|
||||||
working-directory: kubernetes/base
|
working-directory: kubernetes/base
|
||||||
|
|||||||
60
.github/workflows/deploy-dev.yaml
vendored
60
.github/workflows/deploy-dev.yaml
vendored
@ -1,64 +1,42 @@
|
|||||||
|
---
|
||||||
name: Deploy To Development
|
name: Deploy To Development
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- dev
|
- dev
|
||||||
|
|
||||||
paths-ignore:
|
paths-ignore:
|
||||||
- "README.md"
|
- "README.md"
|
||||||
- ".vscode/**"
|
- ".vscode/**"
|
||||||
|
|
||||||
|
- ".github/**"
|
||||||
|
- "!.github/workflows/tests-base.yaml"
|
||||||
|
- "!.github/workflows/deploy-base.yaml"
|
||||||
|
- "!.github/workflows/deploy-dev.yaml"
|
||||||
|
|
||||||
concurrency:
|
concurrency:
|
||||||
group: deploy-dev
|
group: deploy-dev
|
||||||
cancel-in-progress: true
|
cancel-in-progress: true
|
||||||
|
|
||||||
jobs:
|
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:
|
test:
|
||||||
uses: ditkrg/dit-digital-service-manual/.github/workflows/tests-base.yaml@dev
|
uses: ./.github/workflows/tests-base.yaml
|
||||||
|
|
||||||
build-push:
|
build:
|
||||||
name: Build and Push
|
uses: ditkrg/build-image-workflow/.github/workflows/workflow.yaml@v1
|
||||||
needs: [setup, test]
|
needs: test
|
||||||
runs-on: ubuntu-20.04
|
with:
|
||||||
timeout-minutes: 10
|
image: dit-docs/dsm-client
|
||||||
steps:
|
secrets:
|
||||||
- name: Set up Docker Buildx
|
username: ${{ secrets.HARBOR_PUBLIC_USER }}
|
||||||
uses: docker/setup-buildx-action@v1
|
password: ${{ secrets.HARBOR_PUBLIC_TOKEN }}
|
||||||
|
|
||||||
- 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
|
|
||||||
|
|
||||||
deploy:
|
deploy:
|
||||||
uses: ditkrg/dit-digital-service-manual/.github/workflows/deploy-base.yaml@dev
|
uses: ./.github/workflows/deploy-base.yaml
|
||||||
needs: [setup, build-push]
|
needs: build
|
||||||
with:
|
with:
|
||||||
image: ${{ needs.setup.outputs.image-sha }}
|
image: ${{ needs.build.outputs.tag }}
|
||||||
env_url: https://service-manual.docs.dev.krd
|
env_url: https://service-manual.docs.dev.krd
|
||||||
env_name: development
|
env_name: development
|
||||||
|
|
||||||
|
|||||||
60
.github/workflows/deploy-production.yaml
vendored
60
.github/workflows/deploy-production.yaml
vendored
@ -1,64 +1,42 @@
|
|||||||
|
---
|
||||||
name: Deploy To Production
|
name: Deploy To Production
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
|
|
||||||
paths-ignore:
|
paths-ignore:
|
||||||
- "README.md"
|
- "README.md"
|
||||||
- ".vscode/**"
|
- ".vscode/**"
|
||||||
|
|
||||||
|
- ".github/**"
|
||||||
|
- "!.github/workflows/tests-base.yaml"
|
||||||
|
- "!.github/workflows/deploy-base.yaml"
|
||||||
|
- "!.github/workflows/deploy-production.yaml"
|
||||||
|
|
||||||
concurrency:
|
concurrency:
|
||||||
group: deploy-production
|
group: deploy-production
|
||||||
cancel-in-progress: true
|
cancel-in-progress: false
|
||||||
|
|
||||||
jobs:
|
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:
|
test:
|
||||||
uses: ditkrg/dit-digital-service-manual/.github/workflows/tests-base.yaml@main
|
uses: ditkrg/dit-digital-service-manual/.github/workflows/tests-base.yaml@main
|
||||||
|
|
||||||
build-push:
|
build:
|
||||||
name: Build and Push
|
uses: ditkrg/build-image-workflow/.github/workflows/workflow.yaml@v1
|
||||||
needs: [setup, test]
|
needs: test
|
||||||
runs-on: ubuntu-20.04
|
with:
|
||||||
timeout-minutes: 10
|
image: dit-docs/dsm-client
|
||||||
steps:
|
secrets:
|
||||||
- name: Set up Docker Buildx
|
username: ${{ secrets.HARBOR_PUBLIC_USER }}
|
||||||
uses: docker/setup-buildx-action@v1
|
password: ${{ secrets.HARBOR_PUBLIC_TOKEN }}
|
||||||
|
|
||||||
- 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
|
|
||||||
|
|
||||||
deploy:
|
deploy:
|
||||||
uses: ditkrg/dit-digital-service-manual/.github/workflows/deploy-base.yaml@main
|
uses: ./.github/workflows/deploy-base.yaml
|
||||||
needs: [setup, build-push]
|
needs: build
|
||||||
with:
|
with:
|
||||||
image: ${{ needs.setup.outputs.image-sha }}
|
image: ${{ needs.build.outputs.tag }}
|
||||||
env_url: https://docs.digital.gov.krd
|
env_url: https://docs.digital.gov.krd
|
||||||
env_name: production
|
env_name: production
|
||||||
|
|
||||||
|
|||||||
14
.github/workflows/tests-base.yaml
vendored
14
.github/workflows/tests-base.yaml
vendored
@ -1,6 +1,16 @@
|
|||||||
|
---
|
||||||
name: Run Tests
|
name: Run Tests
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
push:
|
||||||
|
branches-ignore:
|
||||||
|
- dev
|
||||||
|
- main
|
||||||
|
|
||||||
|
paths-ignore:
|
||||||
|
- "README.md"
|
||||||
|
- ".vscode/**"
|
||||||
|
|
||||||
workflow_call:
|
workflow_call:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
@ -11,15 +21,13 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Kubectl tool installer
|
- name: Kubectl tool installer
|
||||||
uses: Azure/setup-kubectl@v1
|
uses: Azure/setup-kubectl@v1
|
||||||
|
|
||||||
- name: Setup Kustomize
|
- name: Setup Kustomize
|
||||||
uses: imranismail/setup-kustomize@v1
|
uses: imranismail/setup-kustomize@v1
|
||||||
with:
|
|
||||||
kustomize-version: "4.4.1"
|
|
||||||
|
|
||||||
- name: Build k8s manifests
|
- name: Build k8s manifests
|
||||||
working-directory: kubernetes
|
working-directory: kubernetes
|
||||||
|
|||||||
39
.github/workflows/tests-run.yaml
vendored
39
.github/workflows/tests-run.yaml
vendored
@ -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
|
|
||||||
Loading…
Reference in New Issue
Block a user