Skip to content

Commit 22f2749

Browse files
committed
feat(ci): Automate build and publish
1 parent c6280e4 commit 22f2749

File tree

3 files changed

+99
-1
lines changed

3 files changed

+99
-1
lines changed

.github/workflows/build.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# This workflow will build a docker container, publish it to Azure Container Registry, and deploy it to Azure Kubernetes Service using a helm chart.
2+
#
3+
# https://github.com/Azure/actions-workflow-samples/tree/master/Kubernetes
4+
#
5+
# To configure this workflow:
6+
#
7+
# 1. Set up the following secrets in your workspace:
8+
# a. REGISTRY_USERNAME with ACR username
9+
# b. REGISTRY_PASSWORD with ACR Password
10+
# c. AZURE_CREDENTIALS with the output of `az ad sp create-for-rbac --sdk-auth`
11+
#
12+
# 2. Change the values for the REGISTRY_NAME, CLUSTER_NAME, CLUSTER_RESOURCE_GROUP and NAMESPACE environment variables (below).
13+
name: build
14+
on: [pull_request]
15+
16+
# Environment variables available to all jobs and steps in this workflow
17+
env:
18+
REGISTRY_NAME: k8scc01covidacr
19+
CLUSTER_NAME: k8s-cancentral-02-covid-aks
20+
CLUSTER_RESOURCE_GROUP: k8s-cancentral-01-covid-aks
21+
NAMESPACE: web
22+
23+
jobs:
24+
build:
25+
runs-on: ubuntu-latest
26+
steps:
27+
- uses: actions/checkout@master
28+
29+
# Container build
30+
- run: |
31+
docker build -f Dockerfile -t ${{ env.REGISTRY_NAME }}.azurecr.io/jupyter-apis:${{ github.sha }} .
32+
33+
# Scan image for vulnerabilities
34+
- uses: Azure/container-scan@v0
35+
with:
36+
image-name: ${{ env.REGISTRY_NAME }}.azurecr.io/jupyter-apis:${{ github.sha }}
37+
severity-threshold: CRITICAL
38+
run-quality-checks: false

.github/workflows/publish.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# This workflow will build a docker container, publish it to Azure Container Registry, and deploy it to Azure Kubernetes Service using a helm chart.
2+
#
3+
# https://github.com/Azure/actions-workflow-samples/tree/master/Kubernetes
4+
#
5+
# To configure this workflow:
6+
#
7+
# 1. Set up the following secrets in your workspace:
8+
# a. REGISTRY_USERNAME with ACR username
9+
# b. REGISTRY_PASSWORD with ACR Password
10+
# c. AZURE_CREDENTIALS with the output of `az ad sp create-for-rbac --sdk-auth`
11+
#
12+
# 2. Change the values for the REGISTRY_NAME, CLUSTER_NAME, CLUSTER_RESOURCE_GROUP and NAMESPACE environment variables (below).
13+
name: publish
14+
on:
15+
push:
16+
branches:
17+
- master
18+
19+
# Environment variables available to all jobs and steps in this workflow
20+
env:
21+
REGISTRY_NAME: k8scc01covidacr
22+
CLUSTER_NAME: k8s-cancentral-02-covid-aks
23+
CLUSTER_RESOURCE_GROUP: k8s-cancentral-01-covid-aks
24+
NAMESPACE: web
25+
26+
jobs:
27+
build:
28+
runs-on: ubuntu-latest
29+
steps:
30+
- uses: actions/checkout@master
31+
32+
# Connect to Azure Container registry (ACR)
33+
- uses: azure/docker-login@v1
34+
with:
35+
login-server: ${{ env.REGISTRY_NAME }}.azurecr.io
36+
username: ${{ secrets.REGISTRY_USERNAME }}
37+
password: ${{ secrets.REGISTRY_PASSWORD }}
38+
39+
# Container build and push to a Azure Container registry (ACR)
40+
- run: |
41+
docker build -f Dockerfile -t ${{ env.REGISTRY_NAME }}.azurecr.io/jupyter-apis:${{ github.sha }} .
42+
docker push ${{ env.REGISTRY_NAME }}.azurecr.io/jupyter-apis:${{ github.sha }}
43+
44+
# Scan image for vulnerabilities
45+
- uses: Azure/container-scan@v0
46+
with:
47+
image-name: ${{ env.REGISTRY_NAME }}.azurecr.io/jupyter-apis:${{ github.sha }}
48+
severity-threshold: CRITICAL
49+
run-quality-checks: false
50+
51+
# Prepare to deploy the image
52+
- run: |
53+
sed -i -E 's/[0-9a-f]{40}/${{ github.sha }}/g' deploy/deploy.yaml
54+
55+
# Deploy to Kubernetes
56+
- name: kubectl
57+
uses: statcan/actions/kubectl@master
58+
with:
59+
kubeconfig: ${{ secrets.KUBECONFIG }}
60+
args: apply -f deploy/deploy.yaml

deploy/deploy.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ spec:
2121
app.kubernetes.io/name: jupyter-apis
2222
spec:
2323
containers:
24-
- image: zachomedia/jupyter-apis:latest
24+
- image: k8scc01covidacr.azurecr.io/jupyter-apis:c6280e40c11618c3908449d92f2f67d4e6b17ecc
2525
imagePullPolicy: Always
2626
name: jupyter-web-app
2727
ports:

0 commit comments

Comments
 (0)