From ffd7e3d96fb577656d9b2279790e5a200948dd43 Mon Sep 17 00:00:00 2001 From: James Brumond Date: Sun, 20 Aug 2023 18:52:10 -0700 Subject: [PATCH] add gitea workflow --- .gitea/workflows/build-and-pubilsh.yaml | 44 ++++++++++++++++++++++ .gitea/workflows/build.yaml | 35 ++++++++++++++++++ .gitea/workflows/deploy-prd.yaml | 49 +++++++++++++++++++++++++ .gitea/workflows/deploy-stg.yaml | 49 +++++++++++++++++++++++++ 4 files changed, 177 insertions(+) create mode 100644 .gitea/workflows/build-and-pubilsh.yaml create mode 100644 .gitea/workflows/build.yaml create mode 100644 .gitea/workflows/deploy-prd.yaml create mode 100644 .gitea/workflows/deploy-stg.yaml diff --git a/.gitea/workflows/build-and-pubilsh.yaml b/.gitea/workflows/build-and-pubilsh.yaml new file mode 100644 index 0000000..5c9d6ae --- /dev/null +++ b/.gitea/workflows/build-and-pubilsh.yaml @@ -0,0 +1,44 @@ + +name: Build and publish container images + +on: + workflow_dispatch: { } + # push: + # branches: + # - master + +jobs: + build-and-publish: + runs-on: ubuntu-latest + container: + image: catthehacker/ubuntu:act-latest + steps: + - name: Check out the repo + uses: actions/checkout@v3 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - 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: Build and publish + uses: docker/build-push-action@v4 + env: + # see + ACTIONS_RUNTIME_TOKEN: '' + with: + context: . + push: true + tags: | + gitea.jbrumond.me//:latest + platforms: | + linux/amd64 + linux/arm64 diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml new file mode 100644 index 0000000..8c52abe --- /dev/null +++ b/.gitea/workflows/build.yaml @@ -0,0 +1,35 @@ + +name: Build container images + +on: + workflow_dispatch: { } + push: + branches: + - master + +jobs: + build: + runs-on: ubuntu-latest + container: + image: catthehacker/ubuntu:act-latest + steps: + - name: Check out the repo + uses: actions/checkout@v3 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Build and publish + uses: docker/build-push-action@v4 + env: + # see + ACTIONS_RUNTIME_TOKEN: '' + with: + context: . + push: false + platforms: | + linux/amd64 + linux/arm64 diff --git a/.gitea/workflows/deploy-prd.yaml b/.gitea/workflows/deploy-prd.yaml new file mode 100644 index 0000000..4173f48 --- /dev/null +++ b/.gitea/workflows/deploy-prd.yaml @@ -0,0 +1,49 @@ + +name: Deploy staging to production environment + +on: + workflow_dispatch: { } + # push: + # branches: + # - master + +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//:stg + docker tag gitea.jbrumond.me//:stg gitea.jbrumond.me//:prod + docker push gitea.jbrumond.me//: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 () + run: | + kubectl -n web set image "deployment/" "=gitea.jbrumond.me//:prod" + kubectl -n web rollout restart "deployment/" + kubectl -n web rollout status "deployment/" diff --git a/.gitea/workflows/deploy-stg.yaml b/.gitea/workflows/deploy-stg.yaml new file mode 100644 index 0000000..0566f79 --- /dev/null +++ b/.gitea/workflows/deploy-stg.yaml @@ -0,0 +1,49 @@ + +name: Deploy latest to staging environment + +on: + workflow_dispatch: { } + # push: + # branches: + # - master + +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//:latest + docker tag gitea.jbrumond.me//:latest gitea.jbrumond.me//:stg + docker push gitea.jbrumond.me//: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 () + run: | + kubectl -n web set image "deployment/" "=gitea.jbrumond.me//:stg" + kubectl -n web rollout restart "deployment/" + kubectl -n web rollout status "deployment/"