Skip to content
Snippets Groups Projects
Commit 65e1cfd5 authored by x2004933's avatar x2004933 :confused:
Browse files

Initial scripts

parents
No related branches found
No related tags found
No related merge requests found
public/
results.txt
image: debian:latest
before_script:
- apt-get update
- apt-get install -y git rdfind symlinks findutils sed
pages_test:
stage: test
script:
- cp -a pages.sh pages-exec.sh
- ./pages-exec.sh
- du -sh public/
pages:
stage: deploy
script:
- cp -a pages.sh pages-exec.sh
- ./pages-exec.sh
artifacts:
paths:
- public
only:
- master
cron.sh 0 → 100755
#!/bin/sh
cd $(dirname "$0")
URL="https://www.utwente.nl/en/educational-systems/about_the_applications/canvas/policies/privacy-statement/"
SITE_DIR=site
# Retrieve website
wget -q -O "${SITE_DIR}/index.html" "${URL}"
# Add to Git
git add site
git commit -m "Update at $(date '+%F %T')" >/dev/null
git push
exit 0
<!DOCTYPE html>
<html>
<head>
<title>Canvas Privacy Statement History</title>
</head>
<body>
<article>
<h1>Canvas Privacy Statement History</h1>
<ul>
<li><a href="latest/">latest</a></li>
{{body}}
</ul>
</article>
</body>
</html>
pages.sh 0 → 100755
#!/usr/bin/env bash
set -euo pipefail
site_dir="site"
main_dir=""
pages_dir="public"
template="index.html"
links=""
mkdir "${pages_dir}"
# Get the relevant commits from the log
commits=$(git log --pretty=oneline | grep "Update at" | cut -d' ' -f1)
# Create the website for the relevant commit
for c in $commits
do
# Checkout the relevant commit
git checkout "$c"
# Get the date of the commit
date=$(git show -s --format=%ai "$c")
# Copy the state of the site to the pages dir
cp -a "${site_dir}" "${pages_dir}/${date}"
# Add a link to the index
links="${links}<li><a href=\"${date}/${main_dir}\">${date}</a></li>"
# Create a 'latest' symlink for the latest commit
[ ! -e "${pages_dir}/latest" ] && ln -s "${date}" "${pages_dir}/latest"
done
git checkout master
# Create index file
sed "s|{{body}}|${links}|g" "${template}" > "${pages_dir}/index.html"
# Deduplicate files
rdfind -makesymlinks true "${pages_dir}"
# Make symlinks relative
find "${pages_dir}" -type d -exec symlinks -cs {} +
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment