aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/build.yaml (renamed from .github/workflows/build-deploy.yaml)22
-rw-r--r--.github/workflows/kubernetes-deployment.yaml45
-rw-r--r--deployment.yaml23
3 files changed, 49 insertions, 41 deletions
diff --git a/.github/workflows/build-deploy.yaml b/.github/workflows/build.yaml
index c00f7f6a..514c42e2 100644
--- a/.github/workflows/build-deploy.yaml
+++ b/.github/workflows/build.yaml
@@ -1,4 +1,4 @@
-name: Build & Deploy
+name: Build
on:
workflow_run:
@@ -9,9 +9,9 @@ on:
- completed
jobs:
- build-and-deploy:
- name: Build and Deploy to Kubernetes
- if: github.event.workflow_run.conclusion == 'success'
+ build:
+ name: Build Docker Image
+ if: github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'push'
runs-on: ubuntu-latest
steps:
@@ -54,17 +54,3 @@ jobs:
tags: |
ghcr.io/python-discord/site:latest
ghcr.io/python-discord/site:${{ steps.sha_tag.outputs.tag }}
-
- - name: Authenticate with Kubernetes
- uses: azure/k8s-set-context@v1
- with:
- method: kubeconfig
- kubeconfig: ${{ secrets.KUBECONFIG }}
-
- - name: Deploy to Kubernetes
- uses: Azure/k8s-deploy@v1
- with:
- manifests: |
- deployment.yaml
- images: 'ghcr.io/python-discord/site:${{ steps.sha_tag.outputs.tag }}'
- kubectl-version: 'latest'
diff --git a/.github/workflows/kubernetes-deployment.yaml b/.github/workflows/kubernetes-deployment.yaml
new file mode 100644
index 00000000..ff2652fd
--- /dev/null
+++ b/.github/workflows/kubernetes-deployment.yaml
@@ -0,0 +1,45 @@
+name: Deploy
+
+on:
+ workflow_run:
+ workflows: ["Build"]
+ branches:
+ - master
+ types:
+ - completed
+
+jobs:
+ deploy:
+ if: github.event.workflow_run.conclusion == 'success'
+ name: Deploy to Kubernetes Cluster
+ runs-on: ubuntu-latest
+
+ steps:
+ - name: Create SHA Container Tag
+ id: sha_tag
+ run: |
+ tag=$(cut -c 1-7 <<< $GITHUB_SHA)
+ echo "::set-output name=tag::$tag"
+
+ # Check out the private Kubernetes repository for the
+ # deployment.yaml file using a GitHub Personal Access
+ # Token to get access.
+ - name: Checkout code
+ uses: actions/checkout@v2
+ with:
+ repository: python-discord/kubernetes
+ token: ${{ secrets.REPO_TOKEN }}
+
+ - name: Authenticate with Kubernetes
+ uses: azure/k8s-set-context@v1
+ with:
+ method: kubeconfig
+ kubeconfig: ${{ secrets.KUBECONFIG }}
+
+ - name: Deploy to Kubernetes
+ uses: Azure/k8s-deploy@v1
+ with:
+ manifests: |
+ site/deployment.yaml
+ images: 'ghcr.io/python-discord/site:${{ steps.sha_tag.outputs.tag }}'
+ kubectl-version: 'latest'
diff --git a/deployment.yaml b/deployment.yaml
deleted file mode 100644
index b74e42d4..00000000
--- a/deployment.yaml
+++ /dev/null
@@ -1,23 +0,0 @@
-apiVersion: apps/v1
-kind: Deployment
-metadata:
- name: site
-spec:
- replicas: 1
- selector:
- matchLabels:
- app: site
- template:
- metadata:
- labels:
- app: site
- spec:
- containers:
- - name: site
- image: ghcr.io/python-discord/site:latest
- imagePullPolicy: Always
- ports:
- - containerPort: 8000
- envFrom:
- - secretRef:
- name: site-env