Skip to content

Commit

Permalink
feat: previews (#52)
Browse files Browse the repository at this point in the history
* feat: previews

* fix: trigger
  • Loading branch information
patrickleet committed Oct 26, 2022
1 parent a01e703 commit 974a114
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 0 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ name: pr
on:

pull_request:
branches:
- main

jobs:

Expand Down Expand Up @@ -68,7 +70,41 @@ jobs:
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=ghcr.io/${{ env.REPO }}:buildcache
cache-to: type=registry,ref=ghcr.io/${{ env.REPO }}:buildcache,mode=max

- name: Setup Helm
uses: azure/setup-helm@v3

- name: Checkout App
uses: actions/checkout@v3
with:
path: app

- name: Checkout Preview Environments Project
uses: actions/checkout@v3
with:
path: previews
repository: cloudnativeentrepreneur/example-previews
persist-credentials: false
fetch-depth: 0

- name: create preview from helm template
run:
- helm template app/preview/helm/ --set pr=pr-${{ github.event.pull_request.number }} > previews/helm/templates/pr-${{ github.event.pull_request.number }}.yaml

- name: Commit Prod Env Changes
run: |
cd previews
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add .
git commit -m "feat: Promoting ${{ github.event.repository.name }} to ${{ github.ref_name }}"
- name: Push prod
uses: ad-m/github-push-action@master
with:
path: previews
github_token: ${{ secrets.GH_ORG_TOKEN }}
repository: cloudnativeentrepreneur/example-prod-env
# - name: Setup Kube config
# uses: azure/k8s-set-context@v3
# with:
Expand Down Expand Up @@ -96,3 +132,4 @@ jobs:
# - name: Test
# run: |
# echo "I was to lazy to write tests"

6 changes: 6 additions & 0 deletions preview/helm/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Helm chart.yaml
apiVersion: v1
appVersion: "1.0"
description: A Helm chart for Kubernetes
name: mychart
version: 1.0.0
25 changes: 25 additions & 0 deletions preview/helm/templates/application.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: example-ui-preview-{{ .Values.pr }}
namespace: argocd
finalizers:
- resources-finalizer.argocd.argoproj.io
spec:
project: example-previews
source:
path: helm
repoURL: https://github.com/cloudnativeentrepreneur/sveltekit-web3auth-template.git
targetRevision: {{ .Values.pr }}
helm:
version: v3
values: |
image:
tag: {{ .Values.pr }}
destination:
namespace: example-ui-preview-{{ .Values.pr }}
server: https://kubernetes.default.svc
syncPolicy:
automated:
selfHeal: true
prune: true
1 change: 1 addition & 0 deletions preview/helm/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pr: pr-0

0 comments on commit 974a114

Please sign in to comment.