Files
ttl.sh/.github/workflows/deploy.yml
Marc Campbell b537597c95 Switch from GAR to GHCR for container images
- Update docker-compose.yaml to use ghcr.io/replicatedhq/ttlsh-* images
- Simplify CI auth using GITHUB_TOKEN (no GCP credentials needed)
- Update ansible to use docker login for GHCR instead of gcloud
- Remove google.cloud ansible collection (no longer needed for registry)

GHCR is simpler: automatic auth via GITHUB_TOKEN in Actions,
and packages can be made public for pull access on servers.

Signed-off-by: Marc Campbell <marc.e.campbell@gmail.com>
2026-02-03 11:55:06 +00:00

92 lines
3.2 KiB
YAML

name: Deploy ttl.sh
on:
push:
branches:
- prerelease # Temporary: deploy on prerelease for testing
# - main # TODO: Switch back to main after testing
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@v4
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push images
run: |
# Create empty .env file (docker-compose references it, but it's only needed at runtime)
touch .env
docker compose build
docker compose push
deploy:
name: Deploy to Production
runs-on: ubuntu-latest
needs: build-and-push
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Doppler CLI
uses: dopplerhq/cli-action@v3
- name: Install Ansible
run: |
sudo apt-get update
sudo apt-get install -y ansible
ansible-galaxy collection install community.general community.docker
- name: Setup SSH key
run: |
mkdir -p ~/.ssh
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh-keyscan -H 178.156.198.215 >> ~/.ssh/known_hosts
- name: Run Ansible deployment
working-directory: ./ansible
env:
DOPPLER_TOKEN: ${{ secrets.DOPPLER_TOKEN }}
run: |
ansible-playbook \
-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 "gcloud_sa_email=$(doppler secrets get GOOGLE_APPLICATION_CREDENTIALS_EMAIL --plain)" \
-e "gcloud_sa_key_json=$(doppler secrets get GCS_KEY_ENCODED --plain)" \
-e "gcs_key_encoded=$(doppler secrets get GCS_KEY_ENCODED --plain)" \
-e "hook_token=$(doppler secrets get HOOK_TOKEN --plain)" \
-e "hook_uri=$(doppler secrets get HOOK_URI --plain)" \
-e "redis_password=$(doppler secrets get REDIS_PASSWORD --plain)" \
-e "rediscloud_url=$(doppler secrets get REDISCLOUD_URL --plain)" \
-e "replreg_host=$(doppler secrets get REPLREG_HOST --plain)" \
-e "replreg_secret=$(doppler secrets get REPLREG_SECRET --plain)" \
-e "registry_url=$(doppler secrets get REGISTRY_URL --plain)" \
-e "ghcr_token=$(doppler secrets get GHCR_TOKEN --plain 2>/dev/null || echo '')" \
playbooks/site.yml