Skip to content

Commit 77ac2a1

Browse files
author
Moussa Ouattara
committed
update
1 parent f8fcc4e commit 77ac2a1

File tree

1 file changed

+41
-5
lines changed

1 file changed

+41
-5
lines changed

.github/workflows/helloworld.yml

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
name: helloworld
22

3-
on: push
3+
on: [push]
44

5+
# Environment variables available to all jobs and steps in this workflow
56
env:
6-
REGISTRY_NAME: {registry-name}
7-
CLUSTER_NAME: {cluster-name}
7+
REGISTRY_NAME: moussa
8+
CLUSTER_NAME: mou
89
CLUSTER_RESOURCE_GROUP: {resource-group-name}
9-
# NAMESPACE: {namespace-name}
10-
# APP_NAME: {app-name}
10+
NAMESPACE: default
11+
SECRET: mou
12+
APP_NAME: PORT
1113

1214
jobs:
1315
build:
@@ -27,3 +29,37 @@ jobs:
2729
docker build . -t ${{ env.REGISTRY_NAME }}.azurecr.io/${{ env.APP_NAME }}:${{ github.sha }}
2830
docker push ${{ env.REGISTRY_NAME }}.azurecr.io/${{ env.APP_NAME }}:${{ github.sha }}
2931
working-directory: ./
32+
33+
# Set the target Azure Kubernetes Service (AKS) cluster.
34+
- uses: azure/aks-set-context@v1
35+
with:
36+
creds: '${{ secrets.AZURE_CREDENTIALS }}'
37+
cluster-name: ${{ env.CLUSTER_NAME }}
38+
resource-group: ${{ env.CLUSTER_RESOURCE_GROUP }}
39+
40+
# Create namespace if doesn't exist
41+
- run: |
42+
kubectl create namespace ${{ env.NAMESPACE }} --dry-run=client -o json | kubectl apply -f -
43+
44+
# Create image pull secret for ACR
45+
- uses: azure/k8s-create-secret@v1
46+
with:
47+
container-registry-url: ${{ env.REGISTRY_NAME }}.azurecr.io
48+
container-registry-username: ${{ secrets.REGISTRY_USERNAME }}
49+
container-registry-password: ${{ secrets.REGISTRY_PASSWORD }}
50+
secret-name: ${{ env.SECRET }}
51+
namespace: ${{ env.NAMESPACE }}
52+
arguments: --force true
53+
54+
# Deploy app to AKS
55+
- uses: azure/k8s-deploy@v1
56+
with:
57+
manifests: |
58+
${{ github.workspace }}/manifests/deployment.yaml
59+
${{ github.workspace }}/manifests/service.yaml
60+
images: |
61+
${{ env.REGISTRY_NAME }}.azurecr.io/${{ env.APP_NAME }}:${{ github.sha }}
62+
imagepullsecrets: |
63+
${{ env.SECRET }}
64+
namespace: ${{ env.NAMESPACE }}
65+

0 commit comments

Comments
 (0)