dgnum.eu/.forgejo/workflows/deploy-dgnum.yaml
Tom Hubrecht 0199559447
All checks were successful
Publish website to Codeberg Pages / publish (push) Successful in 25s
fix(workflows): Assume openssh is here
2023-12-15 23:41:14 +01:00

72 lines
2.2 KiB
YAML

name: Publish website to Codeberg Pages
run-name: publish-dgnum.eu
on:
push:
branches:
- master
jobs:
publish:
runs-on: nix
steps:
- uses: actions/checkout@v3
with:
path: dgnum.eu
- name: Build website
run: |
# Hack to set the cache in the working directory
HOME="$GITHUB_WORKSPACE" nix-build dgnum.eu
- name: Push new website
run: |
export HOME="$GITHUB_WORKSPACE"
echo "[+] Using SSH_DEPLOY_KEY"
# Setup deploy key
DEPLOY_KEY_FILE="$HOME/.ssh/deploy_key"
mkdir .ssh
echo "${SSH_DEPLOY_KEY}" > "$DEPLOY_KEY_FILE"
chmod 600 "$DEPLOY_KEY_FILE"
# Setup known hosts
KNOWN_HOSTS_FILE="$HOME/.ssh/known_hosts"
ssh-keyscan -H codeberg.org > "$KNOWN_HOSTS_FILE"
export GIT_SSH_COMMAND="ssh -i $DEPLOY_KEY_FILE -o UserKnownHostsFile=$KNOWN_HOSTS_FILE"
GIT_CMD_REPOSITORY="git@codeberg.org:DGNum/$GIT_REPOSITORY.git"
echo "[+] Cloning remote repository"
git clone --single-branch --depth 1 --branch main "$GIT_CMD_REPOSITORY" "$GIT_REPOSITORY"
git config --global user.email "$GIT_USER_EMAIL"
git config --global user.name "$GIT_USER_NAME"
echo "[+] Updating assets"
rm -r "$GIT_REPOSITORY"/*
# Update assets
cp -R --no-preserve=mode,ownership,timestamps result/* "$GIT_REPOSITORY/"
cd "$GIT_REPOSITORY"
echo "[+] Adding .domains file"
cat << EOL > .domains
dgnum.eu
dev.dgnum.eu
EOL
echo "[+] Creating commit"
ORIGIN_COMMIT="https://$GIT_ORIGIN_SERVER/$GITHUB_REPOSITORY/commit/$GITHUB_SHA"
git add . .domains
git diff-index --quiet HEAD || git commit --message "Automatic pages update from $ORIGIN_COMMIT"
echo "[+] Pushing update"
git push "$GIT_CMD_REPOSITORY" --set-upstream main
env:
SSH_DEPLOY_KEY: ${{ secrets.SSH_DEPLOY_KEY }}
GIT_REPOSITORY: pages
GIT_USER_EMAIL: automated-update@dgnum.eu
GIT_USER_NAME: Forgejo Action
GIT_ORIGIN_SERVER: git.dgnum.eu