trying to make tenv available #9
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: Deploying Wordpress on Kubernetes | |
on: | |
- push | |
- pull_request | |
env: | |
tf_version: 'latest' | |
tg_version: 'latest' | |
tf_working_dir: 'environments/dev' | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ${{ github.repository }} | |
jobs: | |
build-and-push-image: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Log in to the Container registry | |
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push openresty Docker image | |
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc | |
with: | |
context: ./docker | |
file: docker/Dockerfile_openresty | |
push: true | |
tags: ghcr.io/katzefudder/openresty:latest | |
- name: Build and push Wordpress Docker image | |
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc | |
with: | |
context: ./docker | |
file: docker/Dockerfile_wordpress | |
push: true | |
tags: ghcr.io/katzefudder/wordpress:latest | |
Wordpress_on_Minikube: | |
runs-on: ubuntu-latest | |
name: Wordpress on Kubernetes | |
steps: | |
- name: Install tenv | |
run: mkdir tenv && wget https://github.com/tofuutils/tenv/releases/download/v3.2.10/tenv_v3.2.10_Linux_x86_64.tar.gz -O tenv.tar.gz && tar xzf tenv.tar.gz -C tenv && sudo ln -s $(pwd)/tenv/* /usr/local/bin | |
- name: Install helm | |
run: curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 && chmod 700 get_helm.sh && ./get_helm.sh && helm version | |
- name: 'Checkout' | |
uses: actions/checkout@master | |
- name: Install required Terraform & Terragrunt versions | |
run: cd environments && tenv tf install && tenv tg install | |
#### K3D | |
- name: Install K3D | |
run: wget -q -O - https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | TAG=v5.4.4 bash | |
- name: Start K3D | |
run: k3d cluster create --api-port 6550 -p "80:80@loadbalancer" --k3s-arg="--disable=traefik@server:0" | |
#### Install kube-prometheus-stack https://github.com/prometheus-community/helm-charts/tree/main/charts/kube-prometheus-stack | |
# hack: for having CRDs available, install helm chart then remove right after | |
- name: Install kube-prometheus-stack helm chart | |
run: helm repo add prometheus-community https://prometheus-community.github.io/helm-charts && helm repo update && helm install prometheus-stack prometheus-community/kube-prometheus-stack && helm uninstall prometheus-stack | |
- name: Create monitoring namespace | |
run: kubectl create ns monitoring | |
#### Terraforming | |
- name: 'Terragrunt Init' | |
run: cd $tf_working_dir && terragrunt init | |
- name: 'Terragrunt Apply' | |
run: cd $tf_working_dir && terragrunt apply --auto-approve --input=false | |
#### Bit of debugging and testing | |
- name: show running pods | |
run: kubectl get pods -n dev-wordpress | |
- name: port forwarding wordpress to localhost:8080 | |
run: kubectl port-forward -n dev-wordpress svc/wordpress 8080 & | |
- name: testing output | |
run: curl --fail --silent -IL localhost:8080/wp-admin/install.php | grep "HTTP/1.1 200 OK" |