Last active
March 27, 2024 16:08
-
-
Save vfarcic/181614ae807a0cb961271b11bbd18d63 to your computer and use it in GitHub Desktop.
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
# Source: https://gist.github.com/181614ae807a0cb961271b11bbd18d63 | |
###################################### | |
# Github Actions review and tutorial # | |
# https://youtu.be/eZcAvTb0rbA # | |
###################################### | |
# Referenced videos: | |
# - GitHub CLI - How to use manage repositories more efficiently: https://youtu.be/BII6ZY2Rnlc | |
# - Continuous integration, delivery, deployment, and testing explained: https://youtu.be/0ivcSjpUzl4 | |
# - K3d - How to run Kubernetes cluster locally using Rancher k3s: https://youtu.be/mCesuGk-Fks | |
# - Kustomize - How to Simplify Kubernetes Configuration Management: https://youtu.be/Twtbg6LFnAg | |
######### | |
# Setup # | |
######### | |
# Create a Kubernetes cluster with NGINX Ingress | |
gh repo fork vfarcic/github-actions-demo \ | |
--clone | |
cd github-actions-demo | |
# Replace `[...]` with the Docker Hub token | |
export DOCKERHUB_TOKEN=[...] | |
# Replace `[...]` with the Docker Hub user | |
export DOCKERHUB_USERNAME=[...] | |
gh secret set \ | |
DOCKERHUB_TOKEN -b$DOCKERHUB_TOKEN | |
gh secret set \ | |
DOCKERHUB_USERNAME -b$DOCKERHUB_USERNAME | |
# Replace the value with the path to Kube config | |
export KUBECONFIG_PATH=~/.kube/config | |
gh secret set KUBE_CONFIG < $KUBECONFIG_PATH | |
# Replace `[...]` with the external IP of the Ingress service | |
export INGRESS_HOST=[...] | |
cat kustomize/base/ingress.yaml \ | |
| sed -e "s@acme.com@devops-toolkit.$INGRESS_HOST.nip.io@g" \ | |
| tee kustomize/overlays/production/ingress.yaml | |
kubectl create namespace production | |
gh repo view --web | |
# Select the *Actions* tab and click the *I understand my workflows, go ahead and enable them*. | |
################################### | |
# Exploring GitHub Actions syntax # | |
################################### | |
git checkout -b my-feature | |
echo "Is this a feature?" \ | |
| tee something.txt | |
git add . | |
git commit -m "My feature" | |
git push --set-upstream origin my-feature | |
cat Dockerfile | |
cat .github/workflows/pr.yaml | |
########################## | |
# Running GitHub Actions # | |
########################## | |
gh pr create \ | |
--title "My feature" \ | |
--body "Read the title" | |
# Open the address from the output | |
############################# | |
# Exploring other scenarios # | |
############################# | |
cat .github/workflows/main.yaml | |
# If using a Kubernetes platform that references additional tools in Kube config (e.g., GKE needs `gcloud` and EKS requires the authenticator), you might need to use a more specific step instead of `azure/k8s-set-context@v1` | |
# Open https://github.com/marketplace?type=actionsclear | |
gh pr merge | |
echo http://devops-toolkit.$INGRESS_HOST.nip.io | |
# Open it |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment