Use official PrincipleStudios.com domains #74
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: PR Review | |
on: | |
pull_request: | |
types: [opened, reopened, synchronize, ready_for_review] | |
env: | |
azClusterName: PrincipleToolsCluster | |
azClusterResourceGroup: PrincipleK8s | |
registryLoginServer: 'principlestudios.azurecr.io' | |
imageName: 'principle-tools' | |
k8sNamespace: 'principle-tools' | |
releaseName: 'pr-${{ github.event.pull_request.number }}' | |
domainName: 'pr-${{ github.event.pull_request.number }}.tools.principlestudios.com' | |
# Secrets generated via ./deployment/generate-credentials.ps1 - need to be reset regularly | |
jobs: | |
build: | |
runs-on: 'ubuntu-latest' | |
steps: | |
- uses: actions/checkout@v3 | |
- name: 'Log in to docker registry' | |
uses: azure/docker-login@v1 | |
with: | |
login-server: ${{ env.registryLoginServer }} | |
username: ${{ secrets.AZ_CLIENT_ID }} | |
password: ${{ secrets.AZ_CLIENT_SECRET }} | |
- name: 'Build and push image' | |
run: | | |
docker build . -t $registryLoginServer/$imageName:pr-${{ github.sha }} --build-arg GIT_HASH=${{ github.sha }} --build-arg PR_ID=${{ github.event.pull_request.number }} --build-arg DOMAIN=https://pr-${{ github.event.pull_request.number }}.tools.principlestudios.com | |
docker push $registryLoginServer/$imageName:pr-${{ github.sha }} | |
# Set the target Azure Kubernetes Service (AKS) cluster. | |
- uses: azure/login@v1 | |
with: | |
creds: '{"clientId":"${{ secrets.AZ_CLIENT_ID }}","clientSecret":"${{ secrets.AZ_CLIENT_SECRET }}","subscriptionId":"${{ secrets.AZ_SUBSCRIPTION_ID }}","tenantId":"${{ secrets.AZ_TENANT_ID }}"}' | |
- name: Set up kubelogin for non-interactive login | |
uses: azure/use-kubelogin@v1 | |
with: | |
kubelogin-version: 'v0.0.28' | |
- uses: azure/aks-set-context@v3 | |
with: | |
cluster-name: ${{ env.azClusterName }} | |
resource-group: ${{ env.azClusterResourceGroup }} | |
admin: 'false' | |
use-kubelogin: 'true' | |
- name: Helm tool installer | |
uses: Azure/setup-helm@v3 | |
with: | |
version: '3.11.2' | |
- name: 'Deploy' | |
run: | | |
helm repo add ps https://principlestudios.github.io/helm-charts | |
helm repo update ps | |
helm upgrade --install -n $k8sNamespace $releaseName --repo https://principlestudios.github.io/helm-charts single-container \ | |
--set-string "image.repository=$registryLoginServer/$imageName" \ | |
--set-string "image.tag=pr-${{ github.sha }}" \ | |
--set-string "ingress.hosts[0].host=${{ env.domainName }}" \ | |
--set-string "ingress.tls.secretName=principle-tools-tls-pr-${{ github.event.pull_request.number }}" \ | |
--values ./deployment/values.yaml --wait | |
- name: Report PR url | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: 'Branch ready for preview at https://${{ env.domainName }}' | |
}) |