Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: previews #52

Merged
merged 2 commits into from
Oct 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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