Compare commits
No commits in common. "123a0904914077372b7b79a34128308ac164112b" and "a75ca5392ac97e7aa0322c42b8c133b81d5d0b1b" have entirely different histories.
123a090491
...
a75ca5392a
@ -1,27 +0,0 @@
|
|||||||
---
|
|
||||||
name: Deploy website on production server when committing on main
|
|
||||||
concurrency: 1
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
|
|
||||||
defaults:
|
|
||||||
run:
|
|
||||||
shell: bash
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
test:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- run: echo "${{ secrets.SSH_PRIVATE_KEY }}" > /private.key
|
|
||||||
- run: chmod 600 /private.key
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- run: APP_VERSION=latest make
|
|
||||||
- run: |
|
|
||||||
SSH_PRIVATE_KEY=/private.key
|
|
||||||
SSH_USERNAME=${{ secrets.SSH_USERNAME }}
|
|
||||||
DEPLOYMENT_HOST=${{ secrets.DEPLOYMENT_HOST }}
|
|
||||||
DEPLOYMENT_PATH=${{ secrets.DEPLOYMENT_PATH }}
|
|
||||||
make deploy
|
|
4
.vars
4
.vars
@ -1,4 +0,0 @@
|
|||||||
#/usr/bin/env bash
|
|
||||||
|
|
||||||
export DEPLOYMENT_HOST=docker.infra.bjphoster.cloud
|
|
||||||
export DEPLOYMENT_PATH=/opt/pedini.dev
|
|
@ -1,9 +0,0 @@
|
|||||||
+++
|
|
||||||
date = "2024-08-21T20:58:34+02:00"
|
|
||||||
title = "Version Information"
|
|
||||||
url = "/version"
|
|
||||||
+++
|
|
||||||
|
|
||||||
Version: VAR_VERSION
|
|
||||||
Commit ID: [VAR_COMMIT_ID](VAR_COMMIT_URL)
|
|
||||||
Theme Commit ID: [VAR_THEME_COMMIT](VAR_THEME_URL)
|
|
42
deploy.sh
42
deploy.sh
@ -1,42 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
set -e
|
|
||||||
|
|
||||||
###
|
|
||||||
# FLOW
|
|
||||||
###
|
|
||||||
#
|
|
||||||
# if the private key variable is set, prepend "-i" to it
|
|
||||||
# if the username variable is set, append the at sign to it
|
|
||||||
# if either the deployment host or deployment path variables are not set, return an error
|
|
||||||
# tarball the built website and scp it to the deployment host
|
|
||||||
# ssh to the remote host, cd to the deployment path, and get the data path from .env file
|
|
||||||
# then remove everything in the data path, untar the tarball and reload the server
|
|
||||||
# finally remove the tarball, both from the remote host and locally (cleanup)
|
|
||||||
|
|
||||||
# Check if the private key variable is set
|
|
||||||
if [ ! -z "${SSH_PRIVATE_KEY}" ]; then
|
|
||||||
SSH_PRIVATE_KEY="-i ${SSH_PRIVATE_KEY}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check if the username variable is set
|
|
||||||
if [ ! -z "${SSH_USERNAME}" ]; then
|
|
||||||
SSH_USERNAME="${SSH_USERNAME}@"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check if either the deployment host or deployment path variables are not set
|
|
||||||
if [ -z "${DEPLOYMENT_HOST}" ] || [ -z "${DEPLOYMENT_PATH}" ]; then
|
|
||||||
echo "required variable DEPLOYMENT_HOST is not set"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
tar -czf httpdocs.tgz -C public .
|
|
||||||
scp -o StrictHostKeyChecking=no ${SSH_PRIVATE_KEY} httpdocs.tgz ${SSH_USERNAME}${DEPLOYMENT_HOST}:/tmp/httpdocs.tgz
|
|
||||||
ssh -o StrictHostKeyChecking=no ${SSH_PRIVATE_KEY} ${SSH_USERNAME}${DEPLOYMENT_HOST} "DEPLOYMENT_PATH=$DEPLOYMENT_PATH bash" << 'EOF'
|
|
||||||
cd ${DEPLOYMENT_PATH}
|
|
||||||
DATAPATH=$(cat .env | grep "NGINX_DATA" | sed "s/NGINX_DATA=//g")
|
|
||||||
rm -rf ${DATAPATH}/{*,.*}
|
|
||||||
tar xf /tmp/httpdocs.tgz -C ${DATAPATH}
|
|
||||||
docker compose restart
|
|
||||||
rm -f /tmp/httpdocs.tgz
|
|
||||||
EOF
|
|
||||||
rm -f httpdocs.tgz
|
|
45
hugo.yaml
45
hugo.yaml
@ -4,58 +4,24 @@ languageCode: "en-us"
|
|||||||
title: "Bryan Joshua Pedini"
|
title: "Bryan Joshua Pedini"
|
||||||
theme: "hugo-coder"
|
theme: "hugo-coder"
|
||||||
|
|
||||||
markup:
|
|
||||||
goldmark:
|
|
||||||
renderer:
|
|
||||||
hardWraps: true
|
|
||||||
|
|
||||||
params:
|
params:
|
||||||
author: "Bryan Joshua Pedini"
|
author: "Bryan Joshua Pedini"
|
||||||
info: "FullStack Developer - Integration Manager - Cloud/PBX/Network/Docker Specialist - DevOps Enthusiast - Kubernetes/Ceph Apprentice"
|
info: "FullStack developer, Networking/Docker specialist, DevOps enthusiast, k8s newbie, disco lover"
|
||||||
description: "Bryan's personal website / blog"
|
description: "Bryan's personal website / blog"
|
||||||
keywords: "blog,personal,developer,networking,docker,devops,k8s,kubernetes"
|
keywords: "blog,personal,developer,networking,docker,devops,k8s,kubernetes"
|
||||||
gravatar: "bryan@pedini.dev"
|
gravatar: "bryan@pedini.dev"
|
||||||
since: 2019
|
since: 2019
|
||||||
commit: "https://git.bjphoster.com/source/pedini.dev/"
|
commit: "https://git.bjphoster.com/source/pedini.dev/tree/"
|
||||||
colorScheme: "dark"
|
|
||||||
|
|
||||||
csp:
|
|
||||||
childsrc:
|
|
||||||
- self
|
|
||||||
fontsrc:
|
|
||||||
- self
|
|
||||||
formaction:
|
|
||||||
- self
|
|
||||||
framesrc:
|
|
||||||
- self
|
|
||||||
imgsrc:
|
|
||||||
- self
|
|
||||||
objectsrc:
|
|
||||||
- self
|
|
||||||
stylesrc:
|
|
||||||
- self
|
|
||||||
scriptsrc:
|
|
||||||
- self
|
|
||||||
connectsrc:
|
|
||||||
- self
|
|
||||||
|
|
||||||
social:
|
social:
|
||||||
- name: "Git"
|
- name: "Git"
|
||||||
icon: "fa-brands fa-git fa-2x"
|
icon: "fa-brands fa-git fa-2x"
|
||||||
weight: 1
|
weight: 1
|
||||||
url: "https://45r.it/bjphoster-git"
|
url: "https://git.bjphoster.com"
|
||||||
- name: "Instagram"
|
- name: "Instagram"
|
||||||
icon: "fa-brands fa-instagram fa-2x"
|
icon: "fa-brands fa-instagram fa-2x"
|
||||||
weight: 2
|
weight: 2
|
||||||
url: "https://45r.it/pedini-ig"
|
url: "https://instagram.com/bryanp_og/"
|
||||||
- name: "Telegram"
|
|
||||||
icon: "fa-brands fa-telegram fa-2x"
|
|
||||||
weight: 3
|
|
||||||
url: "https://45r.it/pedini-tg"
|
|
||||||
- name: "LinkedIn"
|
|
||||||
icon: "fa-brands fa-linkedin fa-2x"
|
|
||||||
weight: 4
|
|
||||||
url: "https://45r.it/pedini-li"
|
|
||||||
|
|
||||||
menu:
|
menu:
|
||||||
main:
|
main:
|
||||||
@ -68,9 +34,6 @@ menu:
|
|||||||
- name: "Contacts"
|
- name: "Contacts"
|
||||||
weight: 3
|
weight: 3
|
||||||
url: "contacts/"
|
url: "contacts/"
|
||||||
- name: "Version"
|
|
||||||
weight: 4
|
|
||||||
url: "version/"
|
|
||||||
|
|
||||||
taxonomies:
|
taxonomies:
|
||||||
category: "categories"
|
category: "categories"
|
||||||
|
8
makefile
8
makefile
@ -1,16 +1,12 @@
|
|||||||
#!make
|
#!make
|
||||||
include .vars
|
|
||||||
|
|
||||||
default: build
|
default: build
|
||||||
|
|
||||||
prep:
|
prep:
|
||||||
git submodule foreach --recursive bash -c "git checkout $$(git remote show origin | grep HEAD | sed 's/.*\: //'); git pull"
|
git submodule update --init --recursive
|
||||||
|
|
||||||
build: prep
|
build: prep
|
||||||
./version.sh
|
hugo
|
||||||
|
|
||||||
deploy:
|
|
||||||
./deploy.sh
|
|
||||||
|
|
||||||
run: prep
|
run: prep
|
||||||
hugo server
|
hugo server
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit e9dfb36b97f123ae2ef84f6d8082b89eca1d9da4
|
Subproject commit 24cddbe763f967da99b0897d8ac83a142b62718a
|
40
version.sh
40
version.sh
@ -1,40 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
set -e
|
|
||||||
|
|
||||||
# Check if version is already provided
|
|
||||||
if [ -z "${APP_VERSION}"]; then
|
|
||||||
# Get version from user
|
|
||||||
read -p "Version [latest]: " VERSIONINPUT
|
|
||||||
# If version was not provided, use the latest commit short hash as version
|
|
||||||
if [ -z ${VERSIONINPUT} ]; then
|
|
||||||
APP_VERSION="latest"
|
|
||||||
else
|
|
||||||
APP_VERSION=${VERSIONINPUT}
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Get project commit id and URL
|
|
||||||
COMMIT_ID=$(git log HEAD --oneline | awk '{print $1}' | head -n1)
|
|
||||||
COMMIT_URL="$(git remote get-url origin | sed 's/\.git$//g;s/:/\//;s/git@/https:\/\//')/commit/${COMMIT_ID}"
|
|
||||||
|
|
||||||
# Get the theme used and its commit id and URL
|
|
||||||
THEME=$(cat hugo.yaml | grep "theme:" | awk '{print $2}' | sed 's/"//g')
|
|
||||||
pushd themes/${THEME} &>/dev/null
|
|
||||||
THEME_COMMIT=$(git log HEAD --oneline | awk '{print $1}' | head -n1)
|
|
||||||
THEME_URL="$(git remote get-url origin | sed 's/\.git$//g')/commit/${THEME_COMMIT}"
|
|
||||||
popd &>/dev/null
|
|
||||||
|
|
||||||
# Create version tag (if provided)
|
|
||||||
if [ ! -z ${VERSIONINPUT} ]; then
|
|
||||||
git tag ${APP_VERSION}
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Build the website
|
|
||||||
hugo
|
|
||||||
|
|
||||||
# Put the correct version information in the website
|
|
||||||
sed -i "s|VAR_VERSION|${APP_VERSION}|" public/version/index.html
|
|
||||||
sed -i "s|VAR_COMMIT_ID|${COMMIT_ID}|" public/version/index.html
|
|
||||||
sed -i "s|VAR_COMMIT_URL|${COMMIT_URL}|" public/version/index.html
|
|
||||||
sed -i "s|VAR_THEME_URL|${THEME_URL}|" public/version/index.html
|
|
||||||
sed -i "s|VAR_THEME_COMMIT|${THEME_COMMIT}|" public/version/index.html
|
|
Loading…
Reference in New Issue
Block a user