ci: Use local deploy script instead of CI

Further reduce GitHub reliance.
This commit is contained in:
Alexis Sellier 2023-05-10 10:41:01 +02:00
parent b29321dbf7
commit c1d4e87d25
No known key found for this signature in database
3 changed files with 24 additions and 33 deletions

View File

@ -39,34 +39,3 @@ jobs:
tags: gcr.io/radicle-services/radicle-httpd:latest,gcr.io/radicle-services/radicle-httpd:${{ github.sha }}
cache-from: type=registry,ref=gcr.io/radicle-services/radicle-httpd:latest
cache-to: type=inline
deploy-seed-node:
runs-on: ubuntu-latest
needs: build-and-push-images
permissions:
contents: 'read'
id-token: 'write'
strategy:
matrix:
host: [seed]
include:
- host: seed
zone: europe-west4-c
steps:
- id: 'auth'
uses: 'google-github-actions/auth@v0'
with:
workload_identity_provider: 'projects/281042598092/locations/global/workloadIdentityPools/github-actions/providers/google-cloud'
service_account: 'github-actions@radicle-services.iam.gserviceaccount.com'
- name: Fetch host .env file
run: gcloud beta compute ssh --zone ${{ matrix.zone }} "github-actions@alt-clients-${{ matrix.host }}" --project "radicle-services" --command="curl https://raw.githubusercontent.com/${{ github.repository }}/${{ github.sha }}/.env.${{ matrix.host }} >.env"
- name: Fetch docker-compose.yml
run: gcloud beta compute ssh --zone ${{ matrix.zone }} "github-actions@alt-clients-${{ matrix.host }}" --project "radicle-services" --command="curl https://raw.githubusercontent.com/${{ github.repository }}/${{ github.sha }}/docker-compose.yml >docker-compose.yml"
- name: Make room for new images
run: gcloud beta compute ssh --zone ${{ matrix.zone }} "github-actions@alt-clients-${{ matrix.host }}" --project "radicle-services" --command="docker system prune --all --force"
- name: Pull container images
run: gcloud beta compute ssh --zone ${{ matrix.zone }} "github-actions@alt-clients-${{ matrix.host }}" --project "radicle-services" --command="RADICLE_IMAGE_TAG=${{ github.sha }} docker-compose --file docker-compose.yml pull"
- name: Stop services
run: gcloud beta compute ssh --zone ${{ matrix.zone }} "github-actions@alt-clients-${{ matrix.host }}" --project "radicle-services" --command="RADICLE_IMAGE_TAG=${{ github.sha }} docker-compose --file docker-compose.yml down"
- name: Restart services
run: gcloud beta compute ssh --zone ${{ matrix.zone }} "github-actions@alt-clients-${{ matrix.host }}" --project "radicle-services" --command="RADICLE_IMAGE_TAG=${{ github.sha }} docker-compose --file docker-compose.yml up --detach"

View File

@ -10,8 +10,6 @@ services:
RUST_LOG: debug
RAD_PASSPHRASE: seed
RUST_BACKTRACE: 1
GIT_TRACE: 1
GIT_TRACE_PACKET: 1
volumes:
- /mnt/radicle/heartwood:/root/
init: true

24
scripts/deploy-seed Executable file
View File

@ -0,0 +1,24 @@
#!/bin/sh
set -e
HOST=seed.radicle.xyz
BRANCH="$(git rev-parse --abbrev-ref HEAD)"
HEAD="$(git rev-parse HEAD)"
if [ "$BRANCH" != "master" ]; then
echo "You must be on the master branch to run this script."
exit 1
fi
echo "Using commit $HEAD"
echo "Copying files.."
scp .env.seed root@"$HOST":.env
scp docker-compose.yml root@"$HOST":docker-compose.yml
echo "Deploying.."
ssh root@$HOST << EOF
docker system prune --all --force
RADICLE_IMAGE_TAG=$HEAD docker-compose --file docker-compose.yml pull
RADICLE_IMAGE_TAG=$HEAD docker-compose --file docker-compose.yml down
RADICLE_IMAGE_TAG=$HEAD docker-compose --file docker-compose.yml up --detach
EOF