From 5ba55708e939859fa8b78177bbb17b877795db5d Mon Sep 17 00:00:00 2001 From: James Brumond Date: Fri, 18 Aug 2023 19:09:55 -0700 Subject: [PATCH] add deployment workflows; publish an image --- .gitea/workflows/build-and-publish.yaml | 8 ++--- .gitea/workflows/build.yaml | 8 ++--- .gitea/workflows/deploy-prd.yaml | 46 +++++++++++++++++++++++++ .gitea/workflows/deploy-stg.yaml | 46 +++++++++++++++++++++++++ 4 files changed, 100 insertions(+), 8 deletions(-) create mode 100644 .gitea/workflows/deploy-prd.yaml create mode 100644 .gitea/workflows/deploy-stg.yaml diff --git a/.gitea/workflows/build-and-publish.yaml b/.gitea/workflows/build-and-publish.yaml index 0384fa9..e767025 100644 --- a/.gitea/workflows/build-and-publish.yaml +++ b/.gitea/workflows/build-and-publish.yaml @@ -2,10 +2,10 @@ name: Build and publish container images on: -- workflow_dispatch - # push: - # branches: - # - master +# - workflow_dispatch + push: + branches: + - master jobs: build-and-publish: diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml index 6cb2e9a..53031c1 100644 --- a/.gitea/workflows/build.yaml +++ b/.gitea/workflows/build.yaml @@ -2,10 +2,10 @@ name: Build container images on: -# - workflow_dispatch - push: - branches: - - master +- workflow_dispatch + # push: + # branches: + # - master jobs: build: diff --git a/.gitea/workflows/deploy-prd.yaml b/.gitea/workflows/deploy-prd.yaml new file mode 100644 index 0000000..3eed3c5 --- /dev/null +++ b/.gitea/workflows/deploy-prd.yaml @@ -0,0 +1,46 @@ + +name: Deploy staging to production environment + +on: +- workflow_dispatch + +jobs: + tag-image: + runs-on: ubuntu-latest + container: + image: catthehacker/ubuntu:act-latest + steps: + - name: Check out the repo + uses: actions/checkout@v3 + + - name: Log in to the Container registry + uses: docker/login-action@v2 + with: + registry: gitea.jbrumond.me + username: ${{ secrets.REGISTRY_USER }} + password: ${{ secrets.REGISTRY_TOKEN }} + + - name: Tag "stg" with "prod" + run: | + docker pull gitea.jbrumond.me/doc-utils/docs-web:stg + docker tag gitea.jbrumond.me/doc-utils/docs-web:stg gitea.jbrumond.me/doc-utils/docs-web:prod + docker push gitea.jbrumond.me/doc-utils/docs-web:prod + + deploy: + runs-on: ubuntu-latest + container: + image: gitea.jbrumond.me/images/kubectl:1.28 + needs: + - tag-image + env: + KUBERNETES_SERVER: https://nephthys.local.jbrumond.me:6443 + KUBERNETES_TOKEN: ${{ secrets.K8S_WEB_NS_SERVICE_ACCT_TOKEN }} + KUBERNETES_CERT: ${{ secrets.K8S_WEB_NS_SERVICE_ACCT_CERT }} + steps: + - name: Configure kubectl and set credentials + run: /bin/kubectl-setup + - name: Deploy "prod" image to kubernetes production (doc-utils.jbrumond.me) + run: | + kubectl -n web set image "deployment/doc-utils-prod-deploy" "doc-utils-prod=gitea.jbrumond.me/doc-utils/docs-web:prod" + kubectl -n web rollout restart "deployment/doc-utils-prod-deploy" + kubectl -n web rollout status "deployment/doc-utils-prod-deploy" diff --git a/.gitea/workflows/deploy-stg.yaml b/.gitea/workflows/deploy-stg.yaml new file mode 100644 index 0000000..47d6074 --- /dev/null +++ b/.gitea/workflows/deploy-stg.yaml @@ -0,0 +1,46 @@ + +name: Deploy latest to staging environment + +on: +- workflow_dispatch + +jobs: + tag-image: + runs-on: ubuntu-latest + container: + image: catthehacker/ubuntu:act-latest + steps: + - name: Check out the repo + uses: actions/checkout@v3 + + - name: Log in to the Container registry + uses: docker/login-action@v2 + with: + registry: gitea.jbrumond.me + username: ${{ secrets.REGISTRY_USER }} + password: ${{ secrets.REGISTRY_TOKEN }} + + - name: Tag "latest" with "stg" + run: | + docker pull gitea.jbrumond.me/doc-utils/docs-web:latest + docker tag gitea.jbrumond.me/doc-utils/docs-web:latest gitea.jbrumond.me/doc-utils/docs-web:stg + docker push gitea.jbrumond.me/doc-utils/docs-web:stg + + deploy: + runs-on: ubuntu-latest + container: + image: gitea.jbrumond.me/images/kubectl:1.28 + needs: + - tag-image + env: + KUBERNETES_SERVER: https://nephthys.local.jbrumond.me:6443 + KUBERNETES_TOKEN: ${{ secrets.K8S_WEB_NS_SERVICE_ACCT_TOKEN }} + KUBERNETES_CERT: ${{ secrets.K8S_WEB_NS_SERVICE_ACCT_CERT }} + steps: + - name: Configure kubectl and set credentials + run: /bin/kubectl-setup + - name: Deploy "stg" image to kubernetes staging (doc-utils-stg.home.jbrumond.me) + run: | + kubectl -n web set image "deployment/doc-utils-stg-deploy" "doc-utils-stg=gitea.jbrumond.me/doc-utils/docs-web:stg" + kubectl -n web rollout restart "deployment/doc-utils-stg-deploy" + kubectl -n web rollout status "deployment/doc-utils-stg-deploy"