Commit d7b1c133 authored by mrodzis's avatar mrodzis 🌿
Browse files

Bugfix/#44 deploy pages fix

parent 511a3eea
......@@ -18,6 +18,10 @@ build:
- dist/
pages:
before_script:
- dnf install -y jq
- dnf install -y zip
- dnf install -y unzip
image: docker.gitlab.gwdg.de/mgoebel/swiss_knife/fedora:latest
# at the very early stage lets deploy for every branch
# only:
......@@ -30,12 +34,8 @@ pages:
- public
when: always
script:
- curl $(base64 --decode <<< ${wannaBeBlob})/data.tar.gz --output data.tar.gz
- tar -xzf data.tar.gz
- mkdir -p public/${CI_COMMIT_SHORT_SHA}
- cp --remove-destination --recursive dist/spa/* public/${CI_COMMIT_SHORT_SHA}
- mkdir -p public/${CI_COMMIT_REF_SLUG}
- cp --remove-destination --recursive dist/spa/* public/${CI_COMMIT_REF_SLUG}
- bash update-artifacts.sh
- bash gitlab-remove-old-artifacts.sh
environment:
name: ${CI_COMMIT_REF_SLUG}
url: https://subugoe.pages.gwdg.de/emo/Qviewer/${CI_COMMIT_REF_SLUG}/
......@@ -45,11 +45,16 @@ pages:
- public
pushback:
before_script:
- dnf install -y zip
image: docker.gitlab.gwdg.de/mgoebel/swiss_knife/fedora:latest
stage: preserve-pages
script:
- tar -czf data.tar.gz public
- lftp -c "set ssl:verify-certificate no && open $(base64 --decode <<< ${wannaBeBlob}) && put data.tar.gz"
- zip -r updated-artifact.zip public
artifacts:
name: "updated-artifact"
paths:
- updated-artifact.zip
.production:
image: node:latest
......
......@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [0.0.15] - 2020-07-10
### Changed
- The page deployment now takes places without having to store any data externally.
We only rely on previous artifacts for new pipelines.
## [0.0.14] - 2020-06-24
### Fixed
......
#!/bin/bash
#
# Some lines have been commented since they don't work properly at the moment.
# We left them in there as a basis in case we want to improve the performance
# of the build process at a later stage.
#
#active_branches=$(cat $1 | jq '.[].name')
## prepare branch names for BASH regex matching
#active_branches=${active_branches//[\/#]/\-}
#active_branches=${active_branches//\"/}
#active_branches=$(for branch in $active_branches; do echo $branch | tr '[:upper:]' '[:lower:]'; done)
# get current date in seconds–standard procedure for comparing two dates
current_date=$(date "+%Y%m%d")
current_date_in_s=$(date -d $current_date "+%s")
cd public
for entry in *
do
last_modified=$(date -r $entry "+%Y%m%d")
last_modified_in_s=$(date -d $last_modified +%s)
# difference in days
diff=$((($current_date_in_s - $last_modified_in_s) / (24*3600)))
# remove entries that are older than 2 weeks ...
if [[ $diff -gt 14 ]]; then
rm -r $entry
## ... keep the single commit entries ...
#elif [[ ${#entry} == 8 && ${entry} =~ [a-z0-9] ]]; then
# :
## ... but throw away entries of branches that have already been deleted
#elif [[ ! ${active_branches[@]} =~ ${entry} ]]; then
# rm -r $entry
fi
done
File added
#!/bin/bash
# get the latest 'deploy' artifact which contains the former states/environments
jobs=$(curl --header "PRIVATE-TOKEN: $API_TOKEN" "https://gitlab.gwdg.de/api/v4/projects/10921/jobs?scope=success" | jq 'sort_by(.finished_at) | reverse')
latest_deploy_job_id=$(echo $jobs | jq '.[] | select(.stage == "deploy").id' | sed -n 1p)
artifact=$(curl --output old-artifact.zip --header "PRIVATE-TOKEN: $API_TOKEN" "https://gitlab.gwdg.de/api/v4/projects/10921/jobs/$latest_deploy_job_id/artifacts")
# add current data to artifact
unzip -u old-artifact.zip
mkdir -p public/${CI_COMMIT_SHORT_SHA}
cp --remove-destination --recursive dist/spa/* public/${CI_COMMIT_SHORT_SHA}
mkdir -p public/${CI_COMMIT_REF_SLUG}
cp --remove-destination --recursive dist/spa/* public/${CI_COMMIT_REF_SLUG}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment