Skip to content

Commit

Permalink
chore: add github action for deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
mijailr committed Feb 16, 2021
1 parent 549dc35 commit b2cb150
Show file tree
Hide file tree
Showing 5 changed files with 122 additions and 0 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Publish docker image

on:
push:
tags:
- v*

jobs:
release:
runs-on: ubuntu-latest
env:
IMAGE: docker.pkg.github.com/cocreate-app/cocreatews/cocreatews
steps:
- name: Checkout repository
uses: actions/checkout@v1
- name: Login docker registry
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
docker login docker.pkg.github.com -u $GITHUB_ACTOR -p $GITHUB_TOKEN
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
- name: Build docker image
run: docker build . -t $IMAGE:latest -t $IMAGE:${GITHUB_REF:10}
- name: Push docker image
run: |
docker push $IMAGE:latest
docker push $IMAGE:${GITHUB_REF:10}
- name: Get kubectl
run: |
curl -LO https://dl.k8s.io/release/v1.20.0/bin/linux/amd64/kubectl
chmod +x kubectl
- name: Generate deployment
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
sed -i "s/IMAGE_TAG/${GITHUB_REF:10}/g" k8s/kustomization.yaml
./kubectl kustomize k8s/ > manifests/temp.yaml
git stash
git checkout master
mv manifests/temp.yaml manifests/k8sfile.yml
git add manifests/k8sfile.yml
git commit -m "update manifest file"
git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/CoCreate-app/CoCreateWS.git" master -f
27 changes: 27 additions & 0 deletions k8s/daemonset.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
apiVersion: apps/v1
kind: DaemonSet
metadata:
labels:
app: cocreatews
name: cocreatews
namespace: default
spec:
selector:
matchLabels:
app: cocreatews
template:
metadata:
labels:
app: cocreatews
spec:
containers:
- image: cocreatews
imagePullPolicy: Always
name: cocreatews
ports:
- containerPort: 8081
name: app
protocol: TCP
imagePullSecrets:
- name: github
restartPolicy: Always
23 changes: 23 additions & 0 deletions k8s/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
annotations:
nginx.ingress.kubernetes.io/proxy-read-timeout: "3600"
nginx.ingress.kubernetes.io/proxy-send-timeout: "3600"
nginx.ingress.kubernetes.io/affinity: "cookie"
nginx.ingress.kubernetes.io/session-cookie-hash: "sha1"
name: cocreatews
namespace: default
spec:
rules:
- host: "*.cocreate.app"
http:
paths:
- backend:
serviceName: cocreate
servicePort: 8081
path: /
tls:
- hosts:
- "*.cocreate.app"
secretName: cocreate-app
10 changes: 10 additions & 0 deletions k8s/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
resources:
- daemonset.yaml
- service.yaml
- ingress.yaml
commonLabels:
app: cocreatews
images:
- name: cocreatews
newName: docker.pkg.github.com/cocreate-app/cocreatews/cocreatews
newTag: IMAGE_TAG
16 changes: 16 additions & 0 deletions k8s/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: v1
kind: Service
metadata:
name: cocreatews
namespace: default
spec:
ports:
- name: app
port: 8081
protocol: TCP
targetPort: 8081
selector:
app: cocreatews

sessionAffinity: None
type: ClusterIP

0 comments on commit b2cb150

Please sign in to comment.