Use preinstalled Gitea runner tools for production deploy
Deploy HickLab3D Dashboard / Deploy to production (push) Successful in 22s
Deploy HickLab3D Dashboard / Deploy to production (push) Successful in 22s
This commit is contained in:
+16
-100
@@ -12,10 +12,9 @@ permissions:
|
||||
env:
|
||||
PROJECT_NAME: TechOdyssey_Designs_Dashboard
|
||||
DEPLOY_ROOT: /mnt/www-live
|
||||
NODE_VERSION: "22.21.1"
|
||||
REQUIRED_PHP_VERSION: "8.4.0"
|
||||
PHP_CMD: /opt/lhits-toolchain/bin/php
|
||||
COMPOSER_CMD: /opt/lhits-toolchain/bin/composer
|
||||
PHP_CMD: /opt/hicklab3d-toolchain/bin/php
|
||||
COMPOSER_CMD: /opt/hicklab3d-toolchain/bin/composer
|
||||
|
||||
jobs:
|
||||
deploy-production:
|
||||
@@ -24,104 +23,22 @@ jobs:
|
||||
if: github.ref == 'refs/heads/main'
|
||||
|
||||
steps:
|
||||
- name: Inspect runner toolchain
|
||||
- name: Prepare runner toolchain
|
||||
run: |
|
||||
id
|
||||
cat /etc/os-release
|
||||
for tool in git rsync curl xz php php84 composer node npm; do
|
||||
command -v "$tool" || true
|
||||
done
|
||||
|
||||
- name: Install PHP, Composer, Node and deployment tools
|
||||
run: |
|
||||
if command -v apt-get >/dev/null 2>&1; then
|
||||
apt-get update
|
||||
DEBIAN_FRONTEND=noninteractive apt-get install -y \
|
||||
ca-certificates curl gnupg lsb-release software-properties-common \
|
||||
unzip git rsync xz-utils
|
||||
|
||||
. /etc/os-release
|
||||
if [ "${ID:-}" = "ubuntu" ]; then
|
||||
add-apt-repository -y ppa:ondrej/php
|
||||
else
|
||||
curl -fsSL https://packages.sury.org/php/apt.gpg | gpg --dearmor --yes -o /usr/share/keyrings/deb.sury.org-php.gpg
|
||||
echo "deb [signed-by=/usr/share/keyrings/deb.sury.org-php.gpg] https://packages.sury.org/php/ ${VERSION_CODENAME} main" > /etc/apt/sources.list.d/php.list
|
||||
fi
|
||||
|
||||
apt-get update
|
||||
DEBIAN_FRONTEND=noninteractive apt-get install -y \
|
||||
php8.4-cli php8.4-mbstring php8.4-mysql php8.4-xml php8.4-curl \
|
||||
php8.4-zip php8.4-bcmath php8.4-sqlite3 composer
|
||||
|
||||
PHP_BIN="$(command -v php8.4)"
|
||||
elif command -v apk >/dev/null 2>&1; then
|
||||
alpine_series="v$(cut -d. -f1,2 /etc/alpine-release)"
|
||||
printf '%s\n' \
|
||||
"https://dl-cdn.alpinelinux.org/alpine/${alpine_series}/main" \
|
||||
"https://dl-cdn.alpinelinux.org/alpine/${alpine_series}/community" \
|
||||
"https://dl-cdn.alpinelinux.org/alpine/edge/main" \
|
||||
"https://dl-cdn.alpinelinux.org/alpine/edge/community" \
|
||||
> /etc/apk/repositories
|
||||
apk update
|
||||
apk add git rsync curl ca-certificates xz libgcc
|
||||
apk add \
|
||||
php84 php84-cli php84-mbstring php84-xml php84-curl php84-zip php84-phar php84-bcmath php84-ctype \
|
||||
php84-mysqli php84-pdo php84-pdo_mysql php84-pdo_sqlite php84-sqlite3 php84-openssl php84-fileinfo php84-iconv php84-session
|
||||
apk add php84-dom php84-tokenizer php84-xmlwriter php84-session || true
|
||||
|
||||
missing=""
|
||||
for extension in dom iconv pdo_sqlite session sqlite3 tokenizer xmlwriter; do
|
||||
php84 -r "exit(extension_loaded('${extension}') ? 0 : 1);" || missing="${missing} ${extension}"
|
||||
done
|
||||
|
||||
if [ -n "$missing" ]; then
|
||||
apk add php84-dom php84-iconv php84-pdo_sqlite php84-session php84-sqlite3 php84-tokenizer php84-xmlwriter || true
|
||||
fi
|
||||
|
||||
PHP_BIN="$(command -v php84)"
|
||||
curl -fsSL https://getcomposer.org/installer -o /tmp/composer-setup.php
|
||||
"$PHP_BIN" /tmp/composer-setup.php --install-dir=/usr/local/bin --filename=composer
|
||||
else
|
||||
echo "Unsupported package manager for installing PHP/Composer/Node" >&2
|
||||
exit 1
|
||||
fi
|
||||
test -x "$PHP_BIN"
|
||||
command -v git
|
||||
command -v rsync
|
||||
command -v curl
|
||||
command -v node
|
||||
command -v npm
|
||||
|
||||
if [ -z "${PHP_BIN:-}" ] || [ ! -x "$PHP_BIN" ]; then
|
||||
echo "PHP 8.4 binary was not installed or is not executable." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
COMPOSER_BIN="$(command -v composer)"
|
||||
mkdir -p /opt/lhits-toolchain/bin
|
||||
ln -sfn "$PHP_BIN" /opt/lhits-toolchain/bin/php
|
||||
printf '%s\n' '#!/bin/sh' "exec \"$PHP_BIN\" \"$COMPOSER_BIN\" \"\$@\"" > /opt/lhits-toolchain/bin/composer
|
||||
chmod +x /opt/lhits-toolchain/bin/composer
|
||||
"$PHP_CMD" -v
|
||||
|
||||
arch="$(uname -m)"
|
||||
case "$arch" in
|
||||
x86_64) node_arch="x64" ;;
|
||||
aarch64|arm64) node_arch="arm64" ;;
|
||||
*) echo "Unsupported Node architecture: $arch" >&2; exit 1 ;;
|
||||
esac
|
||||
|
||||
if [ -f /etc/alpine-release ] || ldd /bin/sh 2>&1 | grep -qi musl; then
|
||||
node_dir="node-v${NODE_VERSION}-linux-${node_arch}-musl"
|
||||
node_url="https://unofficial-builds.nodejs.org/download/release/v${NODE_VERSION}/${node_dir}.tar.xz"
|
||||
else
|
||||
node_dir="node-v${NODE_VERSION}-linux-${node_arch}"
|
||||
node_url="https://nodejs.org/dist/v${NODE_VERSION}/${node_dir}.tar.xz"
|
||||
fi
|
||||
|
||||
curl -fsSL "$node_url" -o /tmp/node.tar.xz
|
||||
tar -xJf /tmp/node.tar.xz -C /tmp
|
||||
rm -rf /usr/local/lib/nodejs
|
||||
mkdir -p /usr/local/lib/nodejs
|
||||
mv "/tmp/${node_dir}" /usr/local/lib/nodejs/node
|
||||
ln -sfn /usr/local/lib/nodejs/node/bin/node /usr/local/bin/node
|
||||
ln -sfn /usr/local/lib/nodejs/node/bin/npm /usr/local/bin/npm
|
||||
ln -sfn /usr/local/lib/nodejs/node/bin/npx /usr/local/bin/npx
|
||||
hash -r
|
||||
mkdir -p /opt/hicklab3d-toolchain/bin
|
||||
ln -sfn "$PHP_BIN" "$PHP_CMD"
|
||||
curl -fsSL https://getcomposer.org/installer -o /tmp/hicklab3d-composer-setup.php
|
||||
"$PHP_CMD" /tmp/hicklab3d-composer-setup.php --install-dir=/opt/hicklab3d-toolchain/bin --filename=composer.phar
|
||||
printf '%s\n' '#!/bin/sh' 'exec /opt/hicklab3d-toolchain/bin/php /opt/hicklab3d-toolchain/bin/composer.phar "$@"' > "$COMPOSER_CMD"
|
||||
chmod +x "$COMPOSER_CMD"
|
||||
|
||||
- name: Verify runner toolchain
|
||||
run: |
|
||||
@@ -151,8 +68,7 @@ jobs:
|
||||
REPOSITORY: ${{ github.repository }}
|
||||
run: |
|
||||
test -n "$GITEA_TOKEN"
|
||||
git config --global credential.helper '!f() { echo "username=oauth2"; echo "password=$GITEA_TOKEN"; }; f'
|
||||
git clone --depth 1 --single-branch --branch main "https://git.hickmeister.uk/${REPOSITORY}.git" src
|
||||
git -c credential.helper='!f() { echo "username=oauth2"; echo "password=$GITEA_TOKEN"; }; f' clone --depth 1 --single-branch --branch main "https://git.hickmeister.uk/${REPOSITORY}.git" src
|
||||
|
||||
- name: Install dependencies and verify app
|
||||
working-directory: src
|
||||
|
||||
Reference in New Issue
Block a user