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

Commit 3064e59

Browse files
authored
Merge pull request #192 from Azure/s-tuli/AddTemplate
Adding a template for pull request workflow
2 parents 2d09d30 + 4aa000f commit 3064e59

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+
# Note: This template assumes that you use Helm. If not, replace the Helm Install PR step with your own step
2+
# Note: For the secrets below please refer to the document: http://aka.ms/devspaces/pr-flow
3+
#
4+
# Name of the PlaceHolder - Description
5+
########################################################################################################################
6+
# <NAME_OF_THE_WORKFLOW> - Workflow name. example: Bikes
7+
# <PATH_TO_THE_SERVICE> - The path to the service that must be modified in order for the workflow to trigger. - Example: samples/BikeSharingApp/Bikes.
8+
# <PATH_TO_THE_DOCKERFILE> - Path to the directory which contains the DockerFile for the modified service.
9+
# <NAME_OF_THE_SERVICE> - Pass this as a parameter for multiple steps below. Lower Cased Name of the Service, for example: bikes
10+
# <PATH_TO_THE_CHARTS_FOR_THAT_SERVICE> - Pass this in as a parameter for the Helm Install PR step
11+
# Path to the service's helm charts. example: samples/BikeSharingApp/Bikes/charts/bikes
12+
# <RELEASE_NAME> - Pass this in as a parameter for the Helm Install PR step
13+
# More details at Helm documentation at https://helm.sh/docs/helm/#helm-upgrade
14+
# This is [RELEASE] in the helm upgrade [RELEASE] [CHART] [flags] command
15+
# helm upgrade --install command is used for: If a release by this name doesn't already exist, run an install
16+
17+
name: PRFlow <NAME_OF_THE_WORKFLOW>
18+
19+
on:
20+
pull_request:
21+
branches:
22+
- master
23+
paths:
24+
- <PATH_TO_THE_SERVICE>/**
25+
26+
jobs:
27+
build:
28+
runs-on: ubuntu-16.04
29+
steps:
30+
31+
- uses: actions/checkout@master
32+
33+
- uses: azure/container-actions/docker-login@master
34+
with:
35+
login-server: ${{ secrets.CONTAINER_REGISTRY }}
36+
username: ${{ secrets.REGISTRY_USERNAME }}
37+
password: ${{ secrets.REGISTRY_PASSWORD }}
38+
39+
- name: docker build
40+
run: |
41+
docker build <PATH_TO_THE_DOCKERFILE>/ -t ${{ secrets.CONTAINER_REGISTRY }}/<NAME_OF_THE_SERVICE>:$GITHUB_SHA
42+
docker push ${{ secrets.CONTAINER_REGISTRY }}/<NAME_OF_THE_SERVICE>:$GITHUB_SHA
43+
44+
- uses: azure/k8s-actions/aks-set-context@master
45+
with:
46+
creds: '${{ secrets.AZURE_CREDENTIALS }}'
47+
cluster-name: ${{ secrets.CLUSTER_NAME }}
48+
resource-group: ${{ secrets.RESOURCE_GROUP }}
49+
50+
- name: Create child namespaces and add Dev Spaces labels
51+
run: |
52+
if [ -n "$(kubectl get namespace $GITHUB_HEAD_REF --ignore-not-found -o name)" ]; then exit 0; fi
53+
kubectl create namespace $GITHUB_HEAD_REF
54+
kubectl label namespace $GITHUB_HEAD_REF azds.io/parent-space=${{ secrets.MASTER_SPACE }}
55+
kubectl label namespace $GITHUB_HEAD_REF azds.io/space=true
56+
kubectl label namespace $GITHUB_HEAD_REF azds.io/pull-request-space=true
57+
58+
- uses: azure/k8s-actions/k8s-create-secret@master
59+
with:
60+
namespace: ${{ github.head_ref }}
61+
container-registry-url: ${{ secrets.CONTAINER_REGISTRY }}
62+
container-registry-username: ${{ secrets.REGISTRY_USERNAME }}
63+
container-registry-password: ${{ secrets.REGISTRY_PASSWORD }}
64+
secret-name: ${{ secrets.IMAGE_PULL_SECRET }}
65+
66+
- name: Helm Install PR
67+
run: |
68+
helm upgrade --install --namespace $GITHUB_HEAD_REF <RELEASE_NAME>-$GITHUB_HEAD_REF <PATH_TO_THE_CHARTS_FOR_THAT_SERVICE> \
69+
--set image.repository=${{ secrets.CONTAINER_REGISTRY }}/<NAME_OF_THE_SERVICE> \
70+
--set image.tag=$GITHUB_SHA \
71+
--set imagePullSecrets[0].name=${{ secrets.IMAGE_PULL_SECRET }}
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)