test fixed github action #12
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: Deploy Docs (Production) | |
concurrency: documentation | |
on: | |
push: | |
branches: [master, gql, docs/init] | |
jobs: | |
detect-changes: | |
name: Detect Documentation Changes | |
runs-on: ubuntu-latest | |
outputs: | |
changed: ${{ steps.changed.outputs.any_changed }} | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 2 | |
- name: Detect Changed Files | |
uses: tj-actions/changed-files@v45 | |
id: changed | |
with: | |
files: | | |
docs/** | |
build-push: | |
name: Build and Push Docs Image | |
needs: [detect-changes] | |
runs-on: ubuntu-latest | |
if: needs.detect-changes.outputs.any_changed == 'true' | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build and push | |
uses: docker/build-push-action@v6 | |
with: | |
context: docs | |
target: docs-prod | |
tags: ${{ secrets.DOCKER_USERNAME }}/bt-docs:prod | |
cache-from: type=registry,ref=${{ secrets.DOCKER_USERNAME }}/bt-docs:prod-cache | |
cache-to: type=registry,ref=${{ secrets.DOCKER_USERNAME }}/bt-docs:prod-cache,mode=max | |
platforms: linux/amd64 | |
push: true | |
deploy: | |
name: SSH and Deploy | |
needs: [build-push] | |
runs-on: ubuntu-latest | |
environment: documentation | |
steps: | |
- name: SSH and Helm Install | |
uses: appleboy/ssh-action@v1.2.0 | |
with: | |
host: ${{ secrets.SSH_HOST }} | |
username: ${{ secrets.SSH_USERNAME }} | |
key: ${{ secrets.SSH_KEY }} | |
script: | | |
set -e # Exit immediately if a command fails | |
# Check if helm chart exists | |
helm status bt-prod-docs &>/dev/null && status=true || status=false | |
# Upgrade helm chart, or install if not exists | |
helm upgrade bt-prod-docs oci://registry-1.docker.io/octoberkeleytime/bt-docs \ | |
--install \ | |
--version=1.0.0 \ | |
--namespace=bt \ | |
--set host=docs.stanfurdtime.com | |
# Restart deployment if helm chart existed | |
if [ $status = true ]; then | |
kubectl rollout restart deployment bt-prod-docs-docs | |
fi | |
# Check container status | |
kubectl rollout status --timeout=180s deployment bt-prod-docs-docs |