Commit 3c936907 authored by Björn Lindström's avatar Björn Lindström

Tar bort

Det här skriptet hämtar sidan från GitLab till webbservern. Det behövs
inte här eftersom jag använder samma skript som i .
parent 4a844361
Pipeline #62153821 passed with stage
in 1 minute and 45 seconds
#!/usr/bin/env bash
set -o errexit
set -o nounset
# URL - URL, pointing to ZIP file containing single directory named 'public'.
# DIRECTORY - Target directory, to deploy the web site to.
main() {
local artifact_url=$1
local destination=$2
local temp_dir
temp_dir=$(mktemp -d)
local etag_file=".artifact_etag"
local old_etag_file="$destination/$etag_file"
local temp_zip_file="$temp_dir/"
local new_etag_file="$temp_dir/public/$etag_file"
local temp_public_dir="$temp_dir/public"
mkdir "$temp_public_dir"
# Get etag of latest build.
curl --silent --fail --location --head "$artifact_url" \
| grep '^etag: ' \
| tail -1 \
| sed 's/^etag: "\(.*\)"\r$/\1/' \
> "$new_etag_file"
# Return after clean-up if etag matches currently installed version.
if [[ -f "$old_etag_file" ]] && cmp --silent "$old_etag_file" "$new_etag_file"; then
rm -r "$temp_dir"
# Fetch and deploy website.
curl --silent --fail --location "$artifact_url" > "$temp_zip_file"
unzip -q -d "$temp_dir" "$temp_zip_file"
rsync --archive --quiet --delete-delay "$temp_public_dir/" "$destination"
# Clean up.
rm -r "$temp_dir"
main "[email protected]"
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment