mirror of
https://github.com/replicatedhq/ttl.sh.git
synced 2026-08-25 03:07:15 +00:00
124 lines
3.7 KiB
YAML
124 lines
3.7 KiB
YAML
name: Deploy ttl.sh
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- joshs/tuning # Temporary: deploy on prerelease for testing to staging.ttl.sh
|
|
# - main
|
|
workflow_dispatch: # Manual trigger for emergencies
|
|
|
|
concurrency:
|
|
group: deploy-production
|
|
cancel-in-progress: false # Don't cancel in-progress deploys
|
|
|
|
env:
|
|
REGISTRY: ghcr.io
|
|
IMAGE_PREFIX: ghcr.io/${{ github.repository_owner }}/ttlsh
|
|
|
|
jobs:
|
|
build-and-push:
|
|
name: Build & Push Images
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v7
|
|
|
|
- name: Log in to GitHub Container Registry
|
|
uses: docker/login-action@v4
|
|
with:
|
|
registry: ${{ env.REGISTRY }}
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v4
|
|
|
|
- name: Build and push images
|
|
run: |
|
|
docker compose build web zot-ephemeral-ttl
|
|
docker compose push web zot-ephemeral-ttl
|
|
|
|
deploy:
|
|
name: Deploy to Production
|
|
runs-on: ubuntu-latest
|
|
needs: build-and-push
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v7
|
|
|
|
- name: Install Doppler CLI
|
|
uses: dopplerhq/cli-action@v4
|
|
|
|
- name: Install Ansible
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install -y ansible
|
|
ansible-galaxy collection install -r ansible/requirements.yml
|
|
|
|
- name: Resolve VM IP from Doppler
|
|
env:
|
|
DOPPLER_TOKEN: ${{ secrets.DOPPLER_TOKEN }}
|
|
run: |
|
|
VM_IP=$(doppler secrets get LATITUDESH_VM_IP --plain)
|
|
if [ -z "$VM_IP" ]; then
|
|
echo "error: LATITUDESH_VM_IP is empty" >&2
|
|
exit 1
|
|
fi
|
|
echo "VM_IP=$VM_IP" >> "$GITHUB_ENV"
|
|
|
|
- name: Setup SSH key
|
|
run: |
|
|
mkdir -p ~/.ssh
|
|
# Inventory expects the key at ~/.ssh/latitude
|
|
echo "${{ secrets.LATITUDESH_SSH_PRIVATE_KEY }}" > ~/.ssh/latitude
|
|
chmod 600 ~/.ssh/latitude
|
|
ssh-keyscan -H "$VM_IP" >> ~/.ssh/known_hosts
|
|
|
|
- name: Run Ansible deployment
|
|
working-directory: ./ansible
|
|
env:
|
|
DOPPLER_TOKEN: ${{ secrets.DOPPLER_TOKEN }}
|
|
run: |
|
|
ansible-playbook \
|
|
-e "ansible_host=$VM_IP" \
|
|
-e "target_ip=$VM_IP" \
|
|
-e "cloudflare_api_token=$(doppler secrets get CF_API_TOKEN --plain)" \
|
|
-e "cloudflare_zone_id=$(doppler secrets get CF_ZONE_ID --plain)" \
|
|
-e "cloudflare_email=$(doppler secrets get LE_EMAIL --plain)" \
|
|
-e "le_email=$(doppler secrets get LE_EMAIL --plain)" \
|
|
-e "s3_bucket=$(doppler secrets get S3_BUCKET --plain)" \
|
|
-e "s3_region=$(doppler secrets get S3_REGION --plain)" \
|
|
-e "s3_endpoint=$(doppler secrets get S3_ENDPOINT --plain)" \
|
|
-e "s3_access_key=$(doppler secrets get S3_ACCESS_KEY --plain)" \
|
|
-e "s3_secret_key=$(doppler secrets get S3_SECRET_KEY --plain)" \
|
|
playbooks/site.yml
|
|
|
|
smoke-test:
|
|
name: Smoke Test
|
|
runs-on: ubuntu-latest
|
|
needs: deploy
|
|
steps:
|
|
- name: Test push, pull, and expiry
|
|
run: |
|
|
IMAGE="ttl.sh/smoke-${{ github.sha }}:1m"
|
|
|
|
docker pull busybox:latest
|
|
docker tag busybox:latest "$IMAGE"
|
|
docker push "$IMAGE"
|
|
|
|
docker rmi "$IMAGE" busybox:latest
|
|
docker pull "$IMAGE"
|
|
echo "✅ Push/pull passed"
|
|
|
|
docker rmi "$IMAGE"
|
|
sleep 90
|
|
|
|
if docker pull "$IMAGE"; then
|
|
echo "❌ image still pullable after TTL"
|
|
exit 1
|
|
fi
|
|
echo "✅ Image expired as expected"
|