Skip to content

Commit

Permalink
Merge pull request #1012 from Azure/add-pipeline-run
Browse files Browse the repository at this point in the history
Add Pipeline Run Script
  • Loading branch information
janboll authored Jan 6, 2025
2 parents 6050c45 + c874f47 commit 3721aa0
Show file tree
Hide file tree
Showing 6 changed files with 130 additions and 7 deletions.
81 changes: 81 additions & 0 deletions .github/workflows/services-pr-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
---
name: ARO HCP Service PR Check
env:
DEPLOY_ENV: dev
SKIP_CONFIRM: true
on:
pull_request:
paths:
- '.github/workflows/aro-hcp-cd.yml'
- '.github/workflows/environment-infra-cd.yml'
- '.github/workflows/services-cd.yml'
- '.github/workflows/services-ci.yml'
- 'config/config.yaml'
- 'dev-infrastructure/**/*.bicep'
- 'dev-infrastructure/**/*.bicepparam'
- 'dev-infrastructure/configurations/*'
- 'frontend/**'
- 'backend/**'
- 'cluster-service/**'
- 'internal/**'
- 'maestro/**'
- 'pko/**'
- 'acm/**'
- 'hypershiftoperator/**'
- 'image-sync/**/'
- 'tooling/image-sync/**'
- 'tooling/templatize/**'
- 'config/*'
types:
- opened
- synchronize
- reopened

jobs:
service_cluster_pr_check:
permissions:
id-token: 'write'
contents: 'read'
runs-on: 'ubuntu-latest'
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 1

- name: "install azure-cli"
uses: "Azure/ARO-HCP@main"

- name: 'Az CLI login'
uses: azure/login@a65d910e8af852a8061c627c456678983e180302 # v2.2.0
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}

- uses: azure/setup-kubectl@3e0aec4d80787158d308d7b364cb1b702e7feb7f # v4.0.0

# Used to deploy Cluster Service
- name: 'Install oc'
run: |
curl -sfLo - https://mirror.openshift.com/pub/openshift-v4/clients/ocp/4.15.9/openshift-client-linux.tar.gz | tar xzf -
sudo mv oc /usr/local/bin/oc
chmod +x /usr/local/bin/oc
# Used to deploy Maestro Server, Frontend
- uses: azure/setup-helm@fe7b79cd5ee1e45176fcad797de68ecaf3ca4814 # v4.2.0
with:
version: 'v3.13.3'

- uses: azure/use-kubelogin@76597ae0fcbaace21b05e13a2cbf8daee2c6e820 # v1.2
with:
kubelogin-version: 'v0.1.3'

- name: 'Install helm diff'
run: |
helm plugin install https://github.com/databus23/helm-diff
- name: 'Deploy Frontend'
env:
PRINCIPAL_ID: ${{ secrets.GHA_PRINCIPAL_ID }}
run: |
make frontend.dry_run
20 changes: 18 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ infra.clean:
# separator "/" (used for maestro only).

# Services deployed on "svc" aks cluster
services_svc = istio metrics maestro.server maestro.registration cluster-service frontend backend
services_svc = istio metrics maestro.server maestro.registration cluster-service backend
# Services deployed on "mgmt" aks cluster(s)
services_mgmt = acm maestro.agent pko hypershiftoperator
# List of all services
Expand All @@ -120,7 +120,23 @@ services_all = $(join services_svc,services_mgmt)
exit 1;\
fi

svc.deployall: $(addsuffix .deploy, $(services_svc))

# Pipelines section
# This sections is used to reference pipeline runs and should replace
# the usage of `svc-deploh.sh` script in the future.
services_svc_pipelines = frontend
%.deploy:
$(eval export dirname=$(subst .,/,$(basename $@)))
./templatize.sh $(DEPLOY_ENV) -p ./$(dirname)/pipeline.yaml -s deploy -P run -c public

services_svc_pipelines = frontend
%.dry_run:
$(eval export dirname=$(subst .,/,$(basename $@)))
./templatize.sh $(DEPLOY_ENV) -p ./$(dirname)/pipeline.yaml -s deploy -P run -c public -d

services_svc_all = $(join services_svc, services_svc_pipelines)

svc.deployall: $(addsuffix .deploy, $(services_svc_all))
mgmt.deployall: $(addsuffix .deploy, $(services_mgmt))
deployall: svc.deployall mgmt.deployall

Expand Down
3 changes: 2 additions & 1 deletion frontend/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
-include ../setup-env.mk
-include ../helm-cmd.mk

ifndef COMMIT
COMMIT := $(shell git rev-parse --short=7 HEAD)
Expand Down Expand Up @@ -52,7 +53,7 @@ deploy:
TENANT_ID=$(shell az account show --query tenantId --output tsv) && \
kubectl create namespace aro-hcp --dry-run=client -o json | kubectl apply -f - && \
kubectl label namespace aro-hcp "istio.io/rev=$${ISTO_VERSION}" --overwrite=true && \
helm upgrade --install ${HELM_DRY_RUN} aro-hcp-frontend-dev \
${HELM_CMD} aro-hcp-frontend-dev \
deploy/helm/frontend/ \
--set azure.clientId=$${SECRET_STORE_MI_CLIENT_ID} \
--set azure.tenantId=$${TENANT_ID} \
Expand Down
4 changes: 2 additions & 2 deletions frontend/pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ resourceGroups:
command: make deploy
dryRun:
variables:
- name: HELM_DRY_RUN
value: "--dry-run=server --debug"
- name: DRY_RUN
value: "true"
variables:
- name: ARO_HCP_IMAGE_ACR
configRef: svcAcrName
Expand Down
5 changes: 5 additions & 0 deletions helm-cmd.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ifdef DRY_RUN
HELM_CMD ?= helm diff upgrade --install --dry-run=server --suppress-secrets --three-way-merge
else
HELM_CMD ?= helm upgrade --install
endif
24 changes: 22 additions & 2 deletions templatize.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@ CLOUD="${CLOUD:-public}"
REGION="${REGION:-westus3}"
CXSTAMP="${CXSTAMP:-1}"
EXTRA_ARGS=""
PIPELINE_MODE="inspect"
DRY_RUN=""

# Function to display usage
usage() {
echo "Usage: $0 deploy_env input output [-c cloud] [-r region] [-x cxstamp] [-e]"
echo " deploy_env Deployment environment"
echo " input Optional input file"
echo " output Optional output file"
echo " -d Dry run"
echo " -i Set the input file same as second arg"
echo " -o Set the output file same as third arg"
echo " -c Set the cloud (default: public)"
Expand Down Expand Up @@ -45,11 +48,14 @@ if [ "$#" -ge 1 ] && [[ ! "$1" =~ ^- ]]; then
fi

# Parse optional flags
while getopts "c:r:x:e:i:o:p:s:" opt; do
while getopts "c:dr:x:e:i:o:p:P:s:" opt; do
case ${opt} in
c)
CLOUD=${OPTARG}
;;
d)
DRY_RUN="--dry-run"
;;
r)
REGION=${OPTARG}
;;
Expand All @@ -68,6 +74,9 @@ while getopts "c:r:x:e:i:o:p:s:" opt; do
p)
PIPELINE=${OPTARG}
;;
P)
PIPELINE_MODE=${OPTARG}
;;
s)
PIPELINE_STEP=${OPTARG}
;;
Expand Down Expand Up @@ -127,7 +136,7 @@ if [ -n "$INPUT" ] && [ -n "$OUTPUT" ]; then
--input=${INPUT} \
--output=${OUTPUT} \
${EXTRA_ARGS}
elif [ -n "$PIPELINE" ] && [ -n "$PIPELINE_STEP" ]; then
elif [ $PIPELINE_MODE == "inspect" ] && [ -n "$PIPELINE" ] && [ -n "$PIPELINE_STEP" ]; then
$TEMPLATIZE pipeline inspect \
--config-file=${CONFIG_FILE} \
--cloud=${CLOUD} \
Expand All @@ -139,6 +148,17 @@ elif [ -n "$PIPELINE" ] && [ -n "$PIPELINE_STEP" ]; then
--step=${PIPELINE_STEP} \
--scope vars \
--format makefile
elif [ $PIPELINE_MODE == "run" ] && [ -n "$PIPELINE" ] && [ -n "$PIPELINE_STEP" ]; then
$TEMPLATIZE pipeline run \
--config-file=${CONFIG_FILE} \
--cloud=${CLOUD} \
--deploy-env=${DEPLOY_ENV} \
--region=${REGION} \
--region-short=${REGION_STAMP} \
--stamp=${CXSTAMP} \
--pipeline-file=${PIPELINE} \
--step=${PIPELINE_STEP} \
${DRY_RUN}
else
$TEMPLATIZE inspect \
--config-file=${CONFIG_FILE} \
Expand Down

0 comments on commit 3721aa0

Please sign in to comment.