Deploy to S3 instead of rsync

This commit is contained in:
Brandon Rozek 2026-06-07 21:37:47 -04:00
parent 712fb360b2
commit ee8afd7a52
2 changed files with 34 additions and 40 deletions

View file

@ -7,9 +7,6 @@ on:
schedule: schedule:
- cron: "21 14 * * *" - cron: "21 14 * * *"
#concurrency:
# cancel-in-progress: true
defaults: defaults:
run: run:
shell: bash shell: bash
@ -20,21 +17,17 @@ jobs:
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v6
with: with:
submodules: true submodules: true
fetch-depth: 0 fetch-depth: 0
lfs: true
- name: Git submodule update - name: Git submodule update
run: | run: |
git pull --recurse-submodules git pull --recurse-submodules
git submodule update --remote --recursive git submodule update --remote --recursive
- name: Pull down Git LFS files
run: |
git lfs fetch
git lfs checkout
- name: Setup Hugo - name: Setup Hugo
env: env:
HUGO_VERSION: 0.143.1 HUGO_VERSION: 0.143.1
@ -43,41 +36,28 @@ jobs:
tar -xvzf hugo.tar.gz tar -xvzf hugo.tar.gz
sudo mv hugo /usr/local/bin sudo mv hugo /usr/local/bin
- name: Install SSH Key
run: |
install -m 600 -D /dev/null ~/.ssh/id_rsa
echo "${{ secrets.BUILD_SSH_KEY }}" > ~/.ssh/id_rsa
echo "${{ secrets.HOST_KEY }}" > ~/.ssh/known_hosts
cat <<EOL > ~/.ssh/config
Host Rozek-Nimbus
Hostname 158.69.216.99
User build
IdentityFile ~/.ssh/id_rsa
EOL
- name: Build Hugo Website - name: Build Hugo Website
id: build run: hugo
run: |
hugo
- name: Deploy - name: Deploy
env:
AWS_ACCESS_KEY_ID: ${{ secrets.S3_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.S3_APP_KEY }}
AWS_ENDPOINT_URL: ${{ secrets.S3_ENDPOINT }}
S3_BUCKET: rozek-websites
S3_PATH: var/www/brandonrozek
run: ./deploy.sh run: ./deploy.sh
- name: Install Onion SSH Key
run: |
install -m 600 -D /dev/null ~/.ssh/id_onion
echo "${{ secrets.ONION_BUILD_SSH_KEY }}" > ~/.ssh/id_onion
cat <<EOL >> ~/.ssh/config
Host Rozek-Nimbus-Onion
Hostname 158.69.216.99
User build
IdentityFile ~/.ssh/id_onion
EOL
- name: Build Onion Website - name: Build Onion Website
run: | run: |
hugo --baseURL "http://brozek63j22jry6gof2vszo27vh2ed327bqismqu3somrqu622z73eid.onion/" --destination "public-onion" rm -rf public/
hugo --baseURL "http://brozek63j22jry6gof2vszo27vh2ed327bqismqu3somrqu622z73eid.onion/"
- name: Deploy onion website - name: Deploy Onion Website
run: | env:
rsync -Pazc --exclude=*.bak --delete public-onion/ build@Rozek-Nimbus-Onion:brandonrozek-onion/ AWS_ACCESS_KEY_ID: ${{ secrets.S3_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.S3_APP_KEY }}
AWS_ENDPOINT_URL: ${{ secrets.S3_ENDPOINT }}
S3_BUCKET: rozek-websites
S3_PATH: var/www/brandonrozek-onion
run: ./deploy.sh

View file

@ -1,3 +1,17 @@
#!/usr/bin/env sh #!/usr/bin/env sh
rsync -Pazc --exclude=*.bak --delete public/ build@Rozek-Nimbus:brandonrozek/ set -e
: "${AWS_ACCESS_KEY_ID:?AWS_ACCESS_KEY_ID is not set}"
: "${AWS_SECRET_ACCESS_KEY:?AWS_SECRET_ACCESS_KEY is not set}"
: "${AWS_ENDPOINT_URL:?AWS_ENDPOINT_URL is not set}"
: "${S3_BUCKET:?S3_BUCKET is not set}"
: "${S3_PATH:?S3_PATH is not set}"
if [ ! -d "public" ] || [ -z "$(ls -A public)" ]; then
echo "public/ is empty or missing"
exit 1
fi
aws s3 sync public/ "s3://${S3_BUCKET}/${S3_PATH}/" \
--delete \
--exclude "*.bak"