Skip to content

Commit 1e082ad

Browse files
committed
feat: setup kustomize for deploying sha tagged docker image
1 parent 140a2d0 commit 1e082ad

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

.github/workflows/treetracker-wallet-api-build-deploy.yml

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ jobs:
1515
build:
1616
name: Build Server Project
1717
runs-on: ubuntu-latest
18+
if: github.event_name == 'push' && github.repository == 'Greenstand/treetracker-wallet-api'
1819
steps:
1920
- uses: actions/checkout@v2
2021
- name: Use Node.js 12.x
@@ -36,23 +37,18 @@ jobs:
3637
with:
3738
path: ./
3839
- name: Set up QEMU
39-
if: github.event_name == 'push' && github.repository == 'Greenstand/treetracker-wallet-api'
4040
uses: docker/setup-qemu-action@v1
4141
- name: Set up Docker Buildx
42-
if: github.event_name == 'push' && github.repository == 'Greenstand/treetracker-wallet-api'
4342
uses: docker/setup-buildx-action@v1
4443
- name: Login to DockerHub
45-
if: github.event_name == 'push' && github.repository == 'Greenstand/treetracker-wallet-api'
4644
uses: docker/login-action@v1
4745
with:
4846
username: ${{ secrets.DOCKERHUB_USERNAME }}
4947
password: ${{ secrets.DOCKERHUB_TOKEN }}
5048
- name: Set git sha
51-
if: github.event_name == 'push' && github.repository == 'Greenstand/treetracker-wallet-api'
5249
id: git-sha
5350
run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
5451
- name: Build snapshot with git sha and push on merge
55-
if: github.event_name == 'push' && github.repository == 'Greenstand/treetracker-wallet-api'
5652
id: docker_build_snapshot_merge
5753
uses: docker/build-push-action@v2
5854
with:
@@ -61,7 +57,6 @@ jobs:
6157
push: true
6258
tags: greenstand/treetracker-wallet-api:${{ steps.package-version.outputs.current-version }}-${{ steps.git-sha.outputs.sha_short }}
6359
- name: Build snapshot and push on merge
64-
if: github.event_name == 'push' && github.repository == 'Greenstand/treetracker-wallet-api'
6560
id: docker_build_merge
6661
uses: docker/build-push-action@v2
6762
with:
@@ -91,16 +86,24 @@ jobs:
9186
name: Deploy latest to development environment
9287
runs-on: ubuntu-latest
9388
needs: release
89+
if: github.event_name == 'push' && github.repository == 'Greenstand/treetracker-wallet-api'
9490
steps:
9591
- uses: actions/checkout@v2
92+
- name: Set git sha
93+
id: git-sha
94+
run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
95+
- name: Build snapshot with git sha and push on merge
96+
- name: Install kustomize
97+
run: curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash
98+
- name: Copy kustomize.yml
99+
run: cp deployment/kustomize/kustomization.yml deployment/kustomization.yml
100+
- name: Run kustomize
101+
run: (cd deployment && ../kustomize edit set image greenstand/treetracker-wallet-api:${{ steps.git-sha.outputs.sha_short }} )
96102
- name: Install doctl for kubernetes
97-
if: github.event_name == 'push' && github.repository == 'Greenstand/treetracker-wallet-api'
98103
uses: digitalocean/action-doctl@v2
99104
with:
100105
token: ${{ secrets.DIGITALOCEAN_TOKEN }}
101106
- name: Save DigitalOcean kubeconfig
102-
if: github.event_name == 'push' && github.repository == 'Greenstand/treetracker-wallet-api'
103107
run: doctl kubernetes cluster kubeconfig save ${{ secrets.CLUSTER_NAME }}
104108
- name: Update kubernetes resources
105-
if: github.event_name == 'push' && github.repository == 'Greenstand/treetracker-wallet-api'
106-
run: kubectl -n development delete -f ./deployment/ && kubectl -n development apply --wait -f ./deployment/
109+
run: kubectl -n development apply --wait -k ./deployment/
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
resources:
2+
- treetracker-wallet-api-deployment.yaml

0 commit comments

Comments
 (0)