Skip to content

Commit

Permalink
test switch to lftp
Browse files Browse the repository at this point in the history
  • Loading branch information
pickledish committed Apr 14, 2024
1 parent 6897f8b commit 210fb3e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ FROM cruizba/ubuntu-dind:noble-26.0.0

WORKDIR /app

RUN apt-get update && apt-get install -y git ca-certificates git-ftp
RUN apt-get update && apt-get install -y git ca-certificates lftp
RUN update-ca-certificates

ARG VERSION=0.47.6
Expand Down
35 changes: 20 additions & 15 deletions cmd/git/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,38 +10,43 @@ type HookValues struct {
PurgeCacheJwt string
}

var HookTemplate = `#!/bin/bash
var HookTemplate = `#!/usr/bin/env bash
set -euo pipefail
echo "hi..."
echo "you just pushed to {{.SiteId}}, setting up git-ftp..."
echo "you just pushed to {{.SiteId}}!"
git config git-ftp.url "{{.StorageUrl}}"
git config git-ftp.user "{{.StorageName}}"
git config git-ftp.password "{{.StorageToken}}"
git config git-ftp.syncroot "{{.SiteSubDir}}"
while read oldrev newrev refname
do
branch=$(git rev-parse --symbolic --abbrev-ref $refname)
done
echo "checking out main branch..."
echo "you just pushed to branch $branch!"
git checkout main
git config core.bare false
cd ..
# https://stackoverflow.com/questions/10507942
GIT_DIR=".git" git checkout "$branch"
if [ -f "toast.yml" ]; then
echo "file toast.yml found, attempting to build site..."
toast build
echo "file toast.yml found, attempting to build site..."
toast build
else
echo "file toast.yml not found, assuming site is raw HTML..."
echo "file toast.yml not found, assuming site is raw HTML..."
fi
echo "uploading files to CDN..."
git ftp push --auto-init
cd {{.SiteSubDir}}
echo "all uploaded, now purging CDN cache..."
lftp -u {{.StorageName}},{{.StorageToken}} -e "mirror --reverse --parallel=4 --verbose --delete .; bye" {{.StorageUrl}}
# todo, quiet curl
echo "all uploaded, now purging CDN cache..."
curl "{{.PurgeCacheUrl}}" -H "content-type: application/json" -H "Authorization: {{.PurgeCacheJwt}}" -d '{"siteid": "{{.SiteId}}"}'
curl --silent "{{.PurgeCacheUrl}}" -H "content-type: application/json" -H "Authorization: {{.PurgeCacheJwt}}" -d '{"siteid": "{{.SiteId}}"}'
# todo, also need a curl here to supabase to update last_updated_at and deployed_sha
Expand Down
6 changes: 3 additions & 3 deletions toast-local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
image: cruizba/ubuntu-dind:noble-26.0.0
command_prefix: set -euxo pipefail
tasks:
gitftp:
lftp:
command: |
apt-get update
apt-get install -y git ca-certificates git-ftp
apt-get install -y git ca-certificates lftp
update-ca-certificates
toast:
environment:
Expand Down Expand Up @@ -78,7 +78,7 @@ tasks:
input_paths:
- out/cbnr
dependencies:
- gitftp
- lftp
- toast
environment:
PERMISSIVE_MODE: "true"
Expand Down

0 comments on commit 210fb3e

Please sign in to comment.