Skip to content

Commit

Permalink
feat: worflow for dev
Browse files Browse the repository at this point in the history
  • Loading branch information
sayinmehmet47 committed May 4, 2024
1 parent 76ae864 commit ddae6e8
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 2 deletions.
87 changes: 87 additions & 0 deletions .github/workflows/dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: Dev Build & Deploy

on:
push:
branches: [dev]
paths:
- 'client/**'
- 'backend/**'

jobs:
client:
runs-on: ubuntu-latest
if: contains(github.event.head_commit.message, '[client]')
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: set version
run: echo "TAG_VERSION=dev.$(date +'%y-%m-%d').$GITHUB_RUN_NUMBER" >> $GITHUB_ENV

- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push client
uses: docker/build-push-action@v2
with:
context: ./client
file: ./client/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: |
sayinmehmet47/client-kitapkurdu-1:dev
sayinmehmet47/client-kitapkurdu-1:${{ env.TAG_VERSION }}
- name: Deploy to Kubernetes
run: |
kubectl config set-cluster kubernetes \
--server="https://rancher.riwi.dev/k8s/clusters/c-m-cp898j4l"
kubectl config set-credentials github-action \
--token=${{ secrets.KUBE_CONFIG_TOKEN }}
kubectl config set-context default \
--cluster=kubernetes \
--user=github-action
kubectl config use-context default
set image deployment/client-deployment client=sayinmehmet47/client-kitapkurdu-1:${{ env.TAG_VERSION }}
env:
KUBECONFIG: kubeconfig

backend:
runs-on: ubuntu-latest
if: contains(github.event.head_commit.message, '[backend]')
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: set version
run: echo "TAG_VERSION=dev.$(date +'%y-%m-%d').$GITHUB_RUN_NUMBER" >> $GITHUB_ENV

- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push backend
uses: docker/build-push-action@v2
with:
context: ./backend
file: ./backend/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: |
sayinmehmet47/backend-kitapkurdu-1:dev
sayinmehmet47/backend-kitapkurdu-1:${{ env.TAG_VERSION }}
- name: Deploy to Kubernetes
run: |
kubectl config set-cluster kubernetes \
--server="https://rancher.riwi.dev/k8s/clusters/c-m-cp898j4l"
kubectl config set-credentials github-action \
--token=${{ secrets.KUBE_CONFIG_TOKEN }}
kubectl config set-context default \
--cluster=kubernetes \
--user=github-action
kubectl config use-context default
kubectl set image deployment/backend-deployment backend
2 changes: 1 addition & 1 deletion infra/k8s-dev/backend-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ spec:
spec:
containers:
- name: kitapkurdu
image: sayinmehmet47/backend-kitapkurdu-1:latest
image: sayinmehmet47/backend-kitapkurdu-1:dev
env:
- name: MONGO_URI
value: ${{ secrets.MONGO_URI_VALUE }}
Expand Down
2 changes: 1 addition & 1 deletion infra/k8s-dev/frontend-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ spec:
spec:
containers:
- name: frontend
image: sayinmehmet47/client-kitapkurdu-1:latest
image: sayinmehmet47/client-kitapkurdu-1:dev
env:
- name: REACT_APP_LOCAL_API
value: https://dev.kitapkurdu.xyz/api
Expand Down

0 comments on commit ddae6e8

Please sign in to comment.