48 lines
1.5 KiB
YAML
48 lines
1.5 KiB
YAML
name: Deploy documentation
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
|
|
jobs:
|
|
deploy:
|
|
runs-on: oktpserver-deploy
|
|
steps:
|
|
- name: Fetch and deploy
|
|
env:
|
|
GIT_TERMINAL_PROMPT: "0"
|
|
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
|
DEPLOY_SHA: ${{ gitea.sha }}
|
|
run: |
|
|
set -eu
|
|
set +x
|
|
: "${GITEA_TOKEN:?Gitea job token is missing}"
|
|
umask 077
|
|
task_dir=$(mktemp -d)
|
|
trap 'rm -rf -- "$task_dir"' EXIT
|
|
checkout_dir="$task_dir/repository"
|
|
cat > "$task_dir/askpass" <<'SH'
|
|
#!/bin/sh
|
|
case "$1" in
|
|
*Username*) printf '%s\n' 'x-access-token' ;;
|
|
*Password*) printf '%s\n' "$GITEA_TOKEN" ;;
|
|
*) exit 1 ;;
|
|
esac
|
|
SH
|
|
chmod 700 "$task_dir/askpass"
|
|
export GIT_ASKPASS="$task_dir/askpass"
|
|
# Do not read/store credentials via host credential helpers.
|
|
export GIT_CONFIG_COUNT=2
|
|
export GIT_CONFIG_KEY_0=credential.helper
|
|
export GIT_CONFIG_VALUE_0=''
|
|
export GIT_CONFIG_KEY_1=http.followRedirects
|
|
export GIT_CONFIG_VALUE_1=false
|
|
git clone --branch main --single-branch \
|
|
https://sulaco.nodered.ru:5333/COD2/OKTP_SERVER.git "$checkout_dir"
|
|
cd "$checkout_dir"
|
|
if [ "$(git rev-parse HEAD)" != "$DEPLOY_SHA" ]; then
|
|
echo "A newer commit exists; skipping this deployment."
|
|
exit 0
|
|
fi
|
|
bash scripts/deploy.sh
|