dgnum.eu/.forgejo/workflows/deploy-dgnum.yaml

40 lines
1.9 KiB
YAML
Raw Normal View History

jobs:
deploy:
2023-12-15 22:27:48 +01:00
runs-on: nix
steps:
- uses: actions/checkout@v3
with:
path: dgnum.eu
- name: Build the website
run: nix-build dgnum.eu
- env:
GIT_AUTHOR_EMAIL: automated-update@dgnum.eu
GIT_AUTHOR_NAME: Forgejo Action
GIT_COMMITTER_EMAIL: automated-update@dgnum.eu
GIT_COMMITTER_NAME: Forgejo Action
GIT_ORIGIN_SERVER: git.dgnum.eu
GIT_REPOSITORY: pages
SSH_DEPLOY_KEY: ${{ secrets.SSH_DEPLOY_KEY }}
name: Update the website on codeberg
run: "export HOME=\"$GITHUB_WORKSPACE\"\necho \"[+] Using SSH_DEPLOY_KEY\"\n
\n# Setup deploy key\nDEPLOY_KEY_FILE=\"$HOME/.ssh/deploy_key\"\nmkdir .ssh\n
echo \"$SSH_DEPLOY_KEY\" > \"$DEPLOY_KEY_FILE\"\nchmod 600 \"$DEPLOY_KEY_FILE\"\
\n\n# Setup known hosts\nKNOWN_HOSTS_FILE=\"$HOME/.ssh/known_hosts\"\nssh-keyscan
-H codeberg.org > \"$KNOWN_HOSTS_FILE\"\n\nexport GIT_SSH_COMMAND=\"ssh -i
$DEPLOY_KEY_FILE -o UserKnownHostsFile=$KNOWN_HOSTS_FILE\"\nGIT_CMD_REPOSITORY=\"\
git@codeberg.org:DGNum/$GIT_REPOSITORY.git\"\n\necho \"[+] Cloning remote
repository\"\ngit clone --single-branch --depth 1 --branch main \"$GIT_CMD_REPOSITORY\"\
\ \"$GIT_REPOSITORY\"\n\necho \"[+] Updating assets\"\nrm -r \"$GIT_REPOSITORY\"\
/*\n\n# Update assets\ncp -R --no-preserve=mode,ownership,timestamps result/*
\"$GIT_REPOSITORY/\"\ncd \"$GIT_REPOSITORY\"\n\necho \"[+] Adding .domains
file\"\ncat << EOL > .domains\n dgnum.eu\n dev.dgnum.eu\nEOL\n\necho \"
[+] Creating commit\"\nORIGIN_COMMIT=\"https://$GIT_ORIGIN_SERVER/$GITHUB_REPOSITORY/commit/$GITHUB_SHA\"\
\ngit add . .domains\ngit diff-index --quiet HEAD || git commit --message
\"Automatic pages update from $ORIGIN_COMMIT\"\n\necho \"[+] Pushing update\"\
\ngit push \"$GIT_CMD_REPOSITORY\" --set-upstream main\n"
name: Deploy dgnum.eu
on:
push:
branches:
- main