Skip to content
This repository was archived by the owner on Oct 11, 2023. It is now read-only.

Commit 72df1c5

Browse files
committed
Adding a template for pull request workflow
1 parent 7c7f55b commit 72df1c5

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Name of the PlaceHolder - Description
2+
########################################################################################################################
3+
# <Name of the WorkFlow> - Workflow name. example: Bikes
4+
# <Path to the service> - Path to the service where the developer would like to trigger the Flow/ action on pull request - Example: samples/BikeSharingApp/Bikes.
5+
# <Path to the Dockerfile> - Path to the folder which contains the Dockerfile
6+
# <Name of the Service> - Pass this as a parameter for multiple steps below. Lower Cased Name of the Service, for example: bikes
7+
# <Path to the Charts for that service> - Pass this in as a parameter for the Helm Install PR step
8+
# This is the path to the folder where the charts are present for that service. example: samples/BikeSharingApp/Bikes/charts/bikes
9+
# <ReleaseName> - Pass this in as a parameter for the Helm Install PR step
10+
#
11+
# Note: This template assumes that you use Helm. If not, replace the Helm Install PR step with your own step
12+
# Note: For the secrets below please refer to the document: http://aka.ms/devspaces/pr-flow
13+
#
14+
15+
name: PRFlow <Name of the Workflow>
16+
17+
on:
18+
pull_request:
19+
branches:
20+
- master
21+
paths:
22+
- <Path to the Service>/**
23+
24+
jobs:
25+
build:
26+
runs-on: ubuntu-16.04
27+
steps:
28+
29+
- uses: actions/checkout@master
30+
31+
- uses: azure/container-actions/docker-login@master
32+
with:
33+
login-server: ${{ secrets.CONTAINER_REGISTRY }}
34+
username: ${{ secrets.REGISTRY_USERNAME }}
35+
password: ${{ secrets.REGISTRY_PASSWORD }}
36+
37+
- name: docker build
38+
run: |
39+
docker build <Path to the Dockerfile>/ -t ${{ secrets.CONTAINER_REGISTRY }}/<Name of the Service>:$GITHUB_SHA
40+
docker push ${{ secrets.CONTAINER_REGISTRY }}/<Name of the Service>:$GITHUB_SHA
41+
42+
- uses: azure/k8s-actions/aks-set-context@master
43+
with:
44+
creds: '${{ secrets.AZURE_CREDENTIALS }}'
45+
cluster-name: ${{ secrets.CLUSTER_NAME }}
46+
resource-group: ${{ secrets.RESOURCE_GROUP }}
47+
48+
- name: Create child namespaces and add Dev Spaces labels
49+
run: |
50+
if [ -n "$(kubectl get namespace $GITHUB_HEAD_REF --ignore-not-found -o name)" ]; then exit 0; fi
51+
kubectl create namespace $GITHUB_HEAD_REF
52+
kubectl label namespace $GITHUB_HEAD_REF azds.io/parent-space=${{ secrets.MASTER_SPACE }}
53+
kubectl label namespace $GITHUB_HEAD_REF azds.io/space=true
54+
kubectl label namespace $GITHUB_HEAD_REF azds.io/pull-request-space=true
55+
56+
- uses: azure/k8s-actions/k8s-create-secret@master
57+
with:
58+
namespace: ${{ GITHUB_HEAD_REF }}
59+
container-registry-url: ${{ secrets.CONTAINER_REGISTRY }}
60+
container-registry-username: ${{ secrets.REGISTRY_USERNAME }}
61+
container-registry-password: ${{ secrets.REGISTRY_PASSWORD }}
62+
secret-name: ${{ secrets.IMAGE_PULL_SECRET }}
63+
64+
- name: Helm Install PR
65+
run: |
66+
helm upgrade --install --namespace $GITHUB_HEAD_REF <ReleaseName>-$GITHUB_HEAD_REF <Path to the charts for the Service> \
67+
--set image.repository=${{ secrets.CONTAINER_REGISTRY }}/<Name of the Service> \
68+
--set image.tag=$GITHUB_SHA \
69+
--set imagePullSecrets[0].name=${{ secrets.IMAGE_PULL_SECRET }} \
70+
--set ingress.hosts[0]=$GITHUB_HEAD_REF.s.${{ secrets.HOST }} \
71+
--set ingress.annotations.kubernetes\\.io/ingress\\.class=traefik-azds
72+
73+
- uses: azure/dev-spaces/actions/add-review-url@Releases/v1
74+
with:
75+
repo-token: ${{ secrets.GITHUB_TOKEN }}
76+
host: ${{ secrets.HOST }}

0 commit comments

Comments
 (0)