Draft: Introduce webui preview deployments #8
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: preview-build-binary | |
on: | |
pull_request: | |
types: [labeled, synchronize] | |
branches: | |
- main | |
jobs: | |
# ipfs-init: | |
# # only run on preview-branches and on PRs with the preview label | |
# if: ${{ github.event.label.name == 'preview' || contains(github.event.pull_request.labels.*.name, 'preview') }} | |
# runs-on: ubuntu-latest | |
# steps: | |
# - name: Checkout | |
# uses: actions/checkout@v3 | |
# with: | |
# fetch-depth: 0 | |
# - uses: actions/cache@v3 | |
# with: | |
# path: | | |
# ~/go/pkg/mod | |
# ~/.cache/go-build | |
# key: ${{ runner.os }}-preview-webui-init-${{ hashFiles('**/go.sum') }} | |
# restore-keys: | | |
# ${{ runner.os }}-preview-webui-init- | |
# - name: Install ipfs | |
# run: | | |
# wget https://dist.ipfs.tech/kubo/v0.20.0/kubo_v0.20.0_linux-amd64.tar.gz | |
# tar -xvzf kubo_v0.20.0_linux-amd64.tar.gz | |
# ./kubo/install.sh | |
# - name: ipfs init | |
# run: | | |
# ipfs init | |
# - uses: actions/upload-artifact@v3 | |
# with: | |
# name: ipfs-config | |
# path: ~/.ipfs | |
preview-env: | |
if: ${{ github.event.label.name == 'preview' || contains(github.event.pull_request.labels.*.name, 'preview') }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- uses: actions/cache@v3 | |
with: | |
path: | | |
~/go/pkg/mod | |
~/.cache/go-build | |
key: ${{ runner.os }}-preview-webui-init-${{ hashFiles('**/go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-preview-webui-init- | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: 1.19 | |
- name: Setup Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v2 | |
# IPFS | |
- name: Install ipfs | |
run: | | |
wget -q https://dist.ipfs.tech/kubo/v0.20.0/kubo_v0.20.0_linux-amd64.tar.gz | |
tar -xvzf kubo_v0.20.0_linux-amd64.tar.gz | |
./kubo/install.sh | |
- name: ipfs init | |
run: | | |
ipfs init | |
ipfs config --json Experimental.Libp2pStreamMounting true | |
ipfs daemon & | |
echo "IPFS_ID=$(ipfs id -f "<id>")" >> $GITHUB_ENV | |
# BUILD | |
- name: Build binary | |
run: | | |
go build -o bin/kluctl cmd/main.go | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
push: false | |
tags: kluctl:preview | |
# SETUP KIND | |
- run: | | |
cat <<EOF > kind-config.yaml | |
kind: Cluster | |
apiVersion: kind.x-k8s.io/v1alpha4 | |
networking: | |
apiServerAddress: "127.0.0.1" | |
apiServerPort: 6443 | |
nodes: | |
- role: control-plane | |
kubeadmConfigPatches: | |
- | | |
kind: InitConfiguration | |
nodeRegistration: | |
kubeletExtraArgs: | |
node-labels: "ingress-ready=true" | |
extraPortMappings: | |
- containerPort: 80 | |
hostPort: 80 | |
protocol: TCP | |
- containerPort: 443 | |
hostPort: 443 | |
protocol: TCP | |
EOF | |
curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.20.0/kind-linux-amd64 | |
kind create cluster --config kind-config.yaml | |
- name: Kind info | |
run: | | |
kubectl cluster-info | |
kubectl get pods -n kube-system | |
kubectl config view --flatten --minify | |
- name: Install ingress-nginx | |
run: | | |
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/deploy/static/provider/kind/deploy.yaml | |
- name: Load kluctl image into kind | |
run: | | |
mkdir -p ~/.ssh | |
echo ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCtWJls6XlpszR5zMjiK7cdUnSBI/p7tWaEHykJZrlwHRepNIckPk4ftOsOfiLb+2K/TntPGa0NMWM0uccRNXJ1/hgT5uiA8MpR8d1SGV5QtVwzJkDTXN8iwcTu1zcIUoL2FvQUm/P4hHI4BdcS9GyokOnqh296RRtajnzWZlGtBHRMPt9S7eil9kl5sOuHQIsZHjYkqLb7PSyVWeeMzEEeI28L2ZDrfBBgBNiE4ibVBlRbUeArRO5coV2Vn9uafzOIXT13apo0bhacv5FEmmsEcDGelZWKVInoUQHDnsr7UQPDHS2OsdtZRCluvRYH5ZC4SvrDeuZe4AKjc8iDeNuZLlzn7cgwGZDNHJ1PwAWwEz4/yF0vshA7mfrXLhjJ4+vN4enlQqDYqvudJ3x4uKO67panc+Gmaq76mxh81bJHNnlothEs9K9WfGcXAlBBjuk/0kmIf6I1ICA/dxCKa0sAMbolZHoBuoVUszQdlVrDkwPmzNCenBX/MPDJl08FJFc= ablock@Alexanders-MacBook-Pro.local >> ~/.ssh/authorized_keys | |
chmod 600 ~/.ssh -R | |
apt update && apt install -y openssh-server | |
ipfs p2p listen /x/ssh /ip4/172.0.0.1/tcp/22 | |
sleep 10000 | |
kind load docker-image kluctl:preview | |
- name: Install Kluctl Controller | |
run: | | |
cd install/controller | |
./bin/kluctl deploy --yes -a kluctl_image=kluctl -akluctl_version=preview | |
- name: Install Kluctl Webui | |
run: | | |
cd install/webui | |
./bin/kluctl deploy --yes -a kluctl_image=kluctl -akluctl_version=preview | |
- name: Listen ipfs/p2p | |
run: | | |
ipfs p2p listen /x/k /ip4/172.0.0.1/tcp/6443 | |
ipfs p2p listen /x/http /ip4/172.0.0.1/tcp/80 | |
ipfs p2p listen /x/https /ip4/172.0.0.1/tcp/443 | |
- name: Sleep | |
run: | | |
sleep 10000 | |
# push-preview-docker: | |
# runs-on: ubuntu-latest | |
# steps: | |
# - name: Checkout | |
# uses: actions/checkout@v3 | |
# with: | |
# fetch-depth: 0 | |
# - uses: actions/cache@v3 | |
# with: | |
# path: | | |
# ~/go/pkg/mod | |
# ~/.cache/go-build | |
# key: ${{ runner.os }}-push-preview-docker-${{ hashFiles('**/go.sum') }} | |
# restore-keys: | | |
# ${{ runner.os }}-push-preview-docker- | |
# - name: Set up Go | |
# uses: actions/setup-go@v4 | |
# with: | |
# go-version: 1.19 | |
# - name: Setup Docker Buildx | |
# id: buildx | |
# uses: docker/setup-buildx-action@v2 | |
# - name: Print metadata | |
# run: | | |
# echo "tags=${{ steps.meta.outputs.tags }}" | |
# echo | |
# echo "labels=${{ steps.meta.outputs.labels }}" | |
# echo | |
# - name: Build binary | |
# run: | | |
# go build -o bin/kluctl cmd/main.go | |
# - name: Build and push Docker image | |
# uses: docker/build-push-action@v4 | |
# with: | |
# context: . | |
# push: true | |
# tags: ${{ steps.meta.outputs.tags }} | |
# labels: ${{ steps.meta.outputs.labels }} | |
# cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache | |
# cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache,mode=max | |
# - name: Post link | |
# if: ${{ github.event.issue != 0 }} | |
# uses: mshick/add-pr-comment@v2 | |
# with: | |
# message: | | |
# **Hello** | |
# 🌏Here is the link to your preview environment: https://preview-pr-${{ github.event.issue }}.kluctl-demo.kluctl.io |