diff --git a/.github/workflows/deploy-base.yaml b/.github/workflows/deploy-base.yaml new file mode 100644 index 0000000..7ef5198 --- /dev/null +++ b/.github/workflows/deploy-base.yaml @@ -0,0 +1,54 @@ +name: Deploy + +on: + workflow_call: + inputs: + image: + type: string + required: true + env_url: + type: string + required: true + env_name: + type: string + required: true + + secrets: + KUBECONFIG: { required: true } + +env: + NAMESPACE: dit-docs + +jobs: + deploy: + timeout-minutes: 10 + runs-on: [self-hosted, ubuntu-focal] + environment: + url: ${{ inputs.env_url }} + name: ${{ inputs.env_name }} + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Kubectl tool installer + uses: Azure/setup-kubectl@v3 + + - uses: azure/k8s-set-context@v3 + with: + method: kubeconfig + kubeconfig: ${{ secrets.KUBECONFIG }} + + - name: Setup Kustomize + uses: imranismail/setup-kustomize@v2 + + - name: Edit kustomization file + working-directory: kubernetes/base + run: kustomize edit set image IMAGE="${{ inputs.image }}" + + - name: Deploy + working-directory: kubernetes/${{ inputs.env_name }} + run: |- + + kustomize build | kubectl apply -f - + kubectl rollout -n "$NAMESPACE" status deployment/dsm-client-deployment -w --timeout=3m diff --git a/.github/workflows/deploy-dev.yaml b/.github/workflows/deploy-dev.yaml new file mode 100644 index 0000000..c689c7a --- /dev/null +++ b/.github/workflows/deploy-dev.yaml @@ -0,0 +1,45 @@ +--- +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: + test: + uses: ./.github/workflows/tests-base.yaml + + build: + uses: ditkrg/build-image-workflow/.github/workflows/workflow.yaml@v1 + needs: test + with: + image: dit-docs/dsm-client + runs-on: "['ubuntu-latest']" + secrets: + username: ${{ secrets.HARBOR_PUBLIC_USER }} + password: ${{ secrets.HARBOR_PUBLIC_TOKEN }} + + deploy: + uses: ./.github/workflows/deploy-base.yaml + needs: build + with: + image: ${{ needs.build.outputs.tag }} + env_url: https://service-manual.docs.dev.krd + env_name: development + + secrets: + KUBECONFIG: ${{ secrets.KUBECONFIG }} diff --git a/.github/workflows/deploy-production.yaml b/.github/workflows/deploy-production.yaml new file mode 100644 index 0000000..8a6924e --- /dev/null +++ b/.github/workflows/deploy-production.yaml @@ -0,0 +1,45 @@ +--- +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: false + +jobs: + test: + uses: ditkrg/dit-digital-service-manual/.github/workflows/tests-base.yaml@main + + build: + uses: ditkrg/build-image-workflow/.github/workflows/workflow.yaml@v1 + needs: test + with: + image: dit-docs/dsm-client + runs-on: "['ubuntu-latest']" + secrets: + username: ${{ secrets.HARBOR_PUBLIC_USER }} + password: ${{ secrets.HARBOR_PUBLIC_TOKEN }} + + deploy: + uses: ./.github/workflows/deploy-base.yaml + needs: build + with: + image: ${{ needs.build.outputs.tag }} + env_url: https://docs.digital.gov.krd + env_name: production + + secrets: + KUBECONFIG: ${{ secrets.KUBECONFIG }} diff --git a/kubernetes/fleet.yaml b/kubernetes/fleet.yaml deleted file mode 100644 index 4036ab7..0000000 --- a/kubernetes/fleet.yaml +++ /dev/null @@ -1,9 +0,0 @@ -namespace: dit-docs - -targetCustomizations: - - name: development - clusterSelector: - matchLabels: - env: dev - kustomize: - dir: development