Docker Build and Push #321
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: Docker Build and Push | |
on: | |
workflow_dispatch: | |
push: | |
schedule: | |
- cron: '0 0 * * *' # This will run every day at midnight UTC | |
jobs: | |
Test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
# - name: HUGO test build | |
# run: | | |
# docker run --rm -v $(pwd)/blog/:/src -w /src thegeeklab/hugo:latest --panicOnWarning --minify --gc --cleanDestinationDir --destination public --baseURL http://localhost | |
# - name: html-validation | |
# run: | | |
# docker run --rm -v $(pwd)/blog/:/src -w /src thegeeklab/vnu vnu --skip-non-html --errors-only --filterfile .vnuignore public/ | |
- name: Checking for expired content | |
run: | | |
docker run --rm -v $(pwd)/blog/:/src -w /src thegeeklab/hugo:0.122 list expired | |
Build: | |
runs-on: ubuntu-latest | |
needs: Test | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to DockerHub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Docker build and push | |
run: | | |
docker buildx build \ | |
--platform linux/amd64 \ | |
--pull \ | |
--build-arg VERSION="v${{ github.run_number }}" \ | |
--build-arg GIT_COMMIT="${{ github.sha }}" \ | |
--build-arg BUILD_DATE="$(date -u '+%Y-%m-%dT%H:%M:%SZ')" \ | |
--cache-from supporttools/website:latest \ | |
-t supporttools/website:v${{ github.run_number }} \ | |
-t supporttools/website:latest \ | |
--push \ | |
-f Dockerfile . | |
Publish: | |
runs-on: ubuntu-latest | |
needs: Build | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Install gettext | |
run: | | |
sudo apt-get update && sudo apt-get install -y gettext | |
- name: Set up Helm | |
uses: azure/[email protected] | |
- name: Helm Lint | |
run: helm lint charts/website/ | |
- name: Package Helm chart | |
run: | | |
export CHART_VERSION="v${{ github.run_number }}" | |
export APP_VERSION="v${{ github.run_number }}" | |
export IMAGE_TAG="v${{ github.run_number }}" | |
echo "CHART_VERSION=${CHART_VERSION}" | |
echo "APP_VERSION=${APP_VERSION}" | |
echo "IMAGE_TAG=${IMAGE_TAG}" | |
envsubst < charts/website/Chart.yaml.template > charts/website/Chart.yaml | |
envsubst < charts/website/values.yaml.template > charts/website/values.yaml | |
helm package charts/website --destination helm/repo | |
- name: Checkout helm-chart repository | |
uses: actions/checkout@v4 | |
with: | |
repository: SupportTools/helm-chart | |
path: helm-chart | |
token: ${{ secrets.BOT_TOKEN }} | |
- name: Configure Git | |
run: | | |
git config --global user.email "[email protected]" | |
git config --global user.name "GitHub Action" | |
- name: Update Helm repository | |
run: | | |
cp helm/repo/website-*.tgz helm-chart/ | |
cd helm-chart | |
helm repo index . --url https://charts.support.tools/ | |
git add . | |
git commit -m "Update Helm chart for support.tools" | |
git push | |
Deploy-to-NPD: | |
runs-on: ubuntu-latest | |
needs: Publish | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Setup kubectl | |
uses: azure/setup-kubectl@v4 | |
- name: Install and Configure rancher-projects | |
run: | | |
curl -fsSL -o rancher-projects.tar.gz https://github.com/SupportTools/rancher-projects/releases/download/v0.2.2/rancher-projects_0.2.2_linux_amd64.tar.gz | |
tar -xvf rancher-projects.tar.gz | |
chmod +x rancher-projects | |
sudo mv rancher-projects /usr/local/bin/ | |
rancher-projects --rancher-server ${{ secrets.CATTLE_SERVER }} --rancher-access-key ${{ secrets.CATTLE_ACCESS_KEY }} --rancher-secret-key ${{ secrets.CATTLE_SECRET_KEY }} --cluster-name a1-ops-prd --project-name "SupportTools" --namespace supporttools --create-kubeconfig --kubeconfig "kubeconfig" | |
- name: Deploy Master | |
run: | | |
cat ./argocd/mst.yaml | sed "s/CHARTVERSION/v${{ github.run_number }}/g" | kubectl --kubeconfig kubeconfig replace -f - | |
sleep 30 | |
# Wait for the application to become healthy | |
MAX_TRIES=30 | |
SLEEP_TIME=10 | |
COUNTER=0 | |
while [ $COUNTER -lt $MAX_TRIES ]; do | |
HEALTH_STATUS=$(kubectl get applications.argoproj.io supporttools-mst -n argocd -o jsonpath='{.status.health.status}' --kubeconfig kubeconfig) | |
echo "Current health status: $HEALTH_STATUS" | |
if [ "$HEALTH_STATUS" = "Healthy" ]; then | |
echo "Application is healthy." | |
break | |
fi | |
echo "Waiting for application to become healthy..." | |
sleep $SLEEP_TIME | |
let COUNTER=COUNTER+1 | |
done | |
if [ $COUNTER -eq $MAX_TRIES ]; then | |
echo "Application did not become healthy in time." | |
exit 1 | |
fi | |
- name: Deploy Dev | |
run: | | |
cat ./argocd/dev.yaml | sed "s/CHARTVERSION/v${{ github.run_number }}/g" | kubectl --kubeconfig kubeconfig replace -f - | |
sleep 30 | |
# Wait for the application to become healthy | |
MAX_TRIES=30 | |
SLEEP_TIME=10 | |
COUNTER=0 | |
while [ $COUNTER -lt $MAX_TRIES ]; do | |
HEALTH_STATUS=$(kubectl get applications.argoproj.io supporttools-dev -n argocd -o jsonpath='{.status.health.status}' --kubeconfig kubeconfig) | |
echo "Current health status: $HEALTH_STATUS" | |
if [ "$HEALTH_STATUS" = "Healthy" ]; then | |
echo "Application is healthy." | |
break | |
fi | |
echo "Waiting for application to become healthy..." | |
sleep $SLEEP_TIME | |
let COUNTER=COUNTER+1 | |
done | |
if [ $COUNTER -eq $MAX_TRIES ]; then | |
echo "Application did not become healthy in time." | |
exit 1 | |
fi | |
- name: Deploy QAS | |
run: | | |
cat ./argocd/qas.yaml | sed "s/CHARTVERSION/v${{ github.run_number }}/g" | kubectl --kubeconfig kubeconfig replace -f - | |
sleep 30 | |
# Wait for the application to become healthy | |
MAX_TRIES=30 | |
SLEEP_TIME=10 | |
COUNTER=0 | |
while [ $COUNTER -lt $MAX_TRIES ]; do | |
HEALTH_STATUS=$(kubectl get applications.argoproj.io supporttools-qas -n argocd -o jsonpath='{.status.health.status}' --kubeconfig kubeconfig) | |
echo "Current health status: $HEALTH_STATUS" | |
if [ "$HEALTH_STATUS" = "Healthy" ]; then | |
echo "Application is healthy." | |
break | |
fi | |
echo "Waiting for application to become healthy..." | |
sleep $SLEEP_TIME | |
let COUNTER=COUNTER+1 | |
done | |
if [ $COUNTER -eq $MAX_TRIES ]; then | |
echo "Application did not become healthy in time." | |
exit 1 | |
fi | |
- name: Deploy Test | |
run: | | |
cat ./argocd/tst.yaml | sed "s/CHARTVERSION/v${{ github.run_number }}/g" | kubectl --kubeconfig kubeconfig replace -f - | |
sleep 30 | |
# Wait for the application to become healthy | |
MAX_TRIES=30 | |
SLEEP_TIME=10 | |
COUNTER=0 | |
while [ $COUNTER -lt $MAX_TRIES ]; do | |
HEALTH_STATUS=$(kubectl get applications.argoproj.io supporttools-tst -n argocd -o jsonpath='{.status.health.status}' --kubeconfig kubeconfig) | |
echo "Current health status: $HEALTH_STATUS" | |
if [ "$HEALTH_STATUS" = "Healthy" ]; then | |
echo "Application is healthy." | |
break | |
fi | |
echo "Waiting for application to become healthy..." | |
sleep $SLEEP_TIME | |
let COUNTER=COUNTER+1 | |
done | |
if [ $COUNTER -eq $MAX_TRIES ]; then | |
echo "Application did not become healthy in time." | |
exit 1 | |
fi | |
- name: Deploy Staging | |
run: | | |
cat ./argocd/stg.yaml | sed "s/CHARTVERSION/v${{ github.run_number }}/g" | kubectl --kubeconfig kubeconfig replace -f - | |
sleep 30 | |
# Wait for the application to become healthy | |
MAX_TRIES=30 | |
SLEEP_TIME=10 | |
COUNTER=0 | |
while [ $COUNTER -lt $MAX_TRIES ]; do | |
HEALTH_STATUS=$(kubectl get applications.argoproj.io supporttools-stg -n argocd -o jsonpath='{.status.health.status}' --kubeconfig kubeconfig) | |
echo "Current health status: $HEALTH_STATUS" | |
if [ "$HEALTH_STATUS" = "Healthy" ]; then | |
echo "Application is healthy." | |
break | |
fi | |
echo "Waiting for application to become healthy..." | |
sleep $SLEEP_TIME | |
let COUNTER=COUNTER+1 | |
done | |
if [ $COUNTER -eq $MAX_TRIES ]; then | |
echo "Application did not become healthy in time." | |
exit 1 | |
fi | |
Deploy-to-CHI1: | |
runs-on: ubuntu-latest | |
needs: Deploy-to-NPD | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Setup kubectl | |
uses: azure/setup-kubectl@v4 | |
- name: Install and Configure rancher-projects | |
run: | | |
curl -fsSL -o rancher-projects.tar.gz https://github.com/SupportTools/rancher-projects/releases/download/v0.2.2/rancher-projects_0.2.2_linux_amd64.tar.gz | |
tar -xvf rancher-projects.tar.gz | |
chmod +x rancher-projects | |
sudo mv rancher-projects /usr/local/bin/ | |
rancher-projects --rancher-server ${{ secrets.CATTLE_SERVER }} --rancher-access-key ${{ secrets.CATTLE_ACCESS_KEY }} --rancher-secret-key ${{ secrets.CATTLE_SECRET_KEY }} --cluster-name a1-ops-prd --project-name "SupportTools" --namespace supporttools --create-kubeconfig --kubeconfig "kubeconfig" | |
cat ./argocd/prd.yaml | sed "s/CHARTVERSION/v${{ github.run_number }}/g" | kubectl --kubeconfig kubeconfig replace -f - | |
Deploy-to-NYC3: | |
runs-on: ubuntu-latest | |
needs: Deploy-to-NPD | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Setup kubectl | |
uses: azure/setup-kubectl@v4 | |
- name: Install and Configure rancher-projects | |
run: | | |
curl -fsSL -o rancher-projects.tar.gz https://github.com/SupportTools/rancher-projects/releases/download/v0.2.2/rancher-projects_0.2.2_linux_amd64.tar.gz | |
tar -xvf rancher-projects.tar.gz | |
chmod +x rancher-projects | |
sudo mv rancher-projects /usr/local/bin/ | |
rancher-projects --rancher-server ${{ secrets.CATTLE_SERVER }} --rancher-access-key ${{ secrets.CATTLE_ACCESS_KEY }} --rancher-secret-key ${{ secrets.CATTLE_SECRET_KEY }} --cluster-name n3-ops-prd --project-name "SupportTools" --namespace argocd --create-kubeconfig --kubeconfig "kubeconfig" | |
cat ./argocd/prd.yaml | sed "s/CHARTVERSION/v${{ github.run_number }}/g" | kubectl --kubeconfig kubeconfig replace -f - | |
Deploy-to-SFO3: | |
runs-on: ubuntu-latest | |
needs: Deploy-to-NPD | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Setup kubectl | |
uses: azure/setup-kubectl@v4 | |
- name: Install and Configure rancher-projects | |
run: | | |
curl -fsSL -o rancher-projects.tar.gz https://github.com/SupportTools/rancher-projects/releases/download/v0.2.2/rancher-projects_0.2.2_linux_amd64.tar.gz | |
tar -xvf rancher-projects.tar.gz | |
chmod +x rancher-projects | |
sudo mv rancher-projects /usr/local/bin/ | |
rancher-projects --rancher-server ${{ secrets.CATTLE_SERVER }} --rancher-access-key ${{ secrets.CATTLE_ACCESS_KEY }} --rancher-secret-key ${{ secrets.CATTLE_SECRET_KEY }} --cluster-name s3-ops-prd --project-name "SupportTools" --namespace argocd --create-kubeconfig --kubeconfig "kubeconfig" | |
cat ./argocd/prd.yaml | sed "s/CHARTVERSION/v${{ github.run_number }}/g" | kubectl --kubeconfig kubeconfig replace -f - |