generated from ministryofjustice/template-documentation-site
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #493 from ministryofjustice/spaniel-daniel-review
Pages reviewed and updated where appropriate.
- Loading branch information
Showing
24 changed files
with
307 additions
and
174 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,18 @@ | ||
.DEFAULT_GOAL := help | ||
IMAGE := ministryofjustice/tech-docs-github-pages-publisher:1.4 | ||
|
||
# Use this to run a local instance of the documentation site, while editing | ||
.PHONY: preview | ||
preview: | ||
.PHONY: preview report | ||
|
||
preview: ## Run a local instance of the documentation site, while editing | ||
docker run --rm \ | ||
-v $$(pwd)/config:/app/config \ | ||
-v $$(pwd)/source:/app/source \ | ||
-p 4567:4567 \ | ||
-it $(IMAGE) /publishing-scripts/preview.sh | ||
|
||
|
||
report: ## Review which pages have expired | ||
./report-for-daniel-the-manual-spaniel.sh | ||
|
||
help: | ||
@grep -h -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
#!/usr/bin/env bash | ||
|
||
## Simple script to quickly review which pages have expired and which are due | ||
## to expire in next three weeks. | ||
|
||
function check_dependencies () { | ||
|
||
if ! command -v ag; then | ||
echo -e "\nThe silver searcher is required to run this script" | ||
echo -e "https://github.com/ggreer/the_silver_searcher \n" | ||
exit 1 | ||
fi | ||
|
||
if ! command -v datediff >/dev/null 2>&1; then | ||
echo -e "\ndatediff is required to run this script" | ||
echo "it is part of 'dateutils' - install with brew or os package manager" | ||
echo -e "https://github.com/hroptatyr/dateutils \n" | ||
exit 1 | ||
fi | ||
} | ||
|
||
function readlines () { | ||
local N="$1" | ||
local line | ||
local rc="1" | ||
|
||
# Read at most N lines | ||
for i in $(seq 1 $N) | ||
do | ||
# Try reading a single line | ||
read line | ||
if [ $? -eq 0 ] | ||
then | ||
# Output line | ||
echo $line | ||
rc="0" | ||
else | ||
break | ||
fi | ||
done | ||
|
||
# Return 1 if no lines where read | ||
return $rc | ||
} | ||
|
||
run_report () { | ||
local report | ||
local today | ||
local expiring_pages | ||
local expired_pages | ||
|
||
local last_reviewed_on | ||
local review_in | ||
local expiry | ||
local expiry_diff | ||
|
||
report=$(ag last_reviewed_on -A 1 --ignore "*.txt" --ignore "*.sh" --group) | ||
today=$(date '+%Y-%m-%d') | ||
expiring_pages="Following pages expiring in next 3 weeks:\n" | ||
expired_pages="Following pages have expired:\n" | ||
|
||
while chunk=$(readlines 4) | ||
do | ||
echo "******************************************************************************************" | ||
echo "$chunk" | ||
echo "" | ||
|
||
last_reviewed_on="$(echo "$chunk" | grep "last_reviewed_on" | cut -d " " -f 2)" | ||
echo "last_reviewed_on: ${last_reviewed_on}" | ||
|
||
review_in="$(echo "$chunk" | grep "review_in" | cut -d " " -f 2)" | ||
echo "review_in: ${review_in}" | ||
|
||
review_in_days=$(expr ${review_in} \* 30) | ||
echo "review_in_days: ${review_in_days}" | ||
|
||
expiry=$(date -d "${last_reviewed_on}+${review_in_days}days" '+%Y-%m-%d') | ||
echo "expiry: ${expiry}" | ||
|
||
expiry_diff=$(datediff ${today} ${expiry}) | ||
echo "expiry_diff: ${expiry_diff}" | ||
|
||
page="$(echo "$chunk" | grep "source" | cut -d "/" -f1-)" | ||
|
||
if [[ ${expiry_diff} -gt 0 ]];then | ||
echo "****** fine ${page} *****" | ||
|
||
if [[ ${expiry_diff} -lt 21 ]];then | ||
echo "****** due ${page} *****" | ||
expiring_pages+="$(echo -e "\nExpiring in ${expiry_diff} days: ${page}")" | ||
fi | ||
else | ||
echo "****** review ${page} *****" | ||
expired_pages+="$(echo -e "\nExpired ${expiry_diff} days ago: ${page}")" | ||
fi | ||
|
||
echo "******************************************************************************************" | ||
echo "" | ||
echo "" | ||
done <<<"${report}" | ||
|
||
echo "" | ||
echo "" | ||
echo -e "${expiring_pages}" | ||
|
||
echo "" | ||
echo "" | ||
echo -e "${expired_pages}" | ||
echo "" | ||
echo "" | ||
} | ||
|
||
main() { | ||
check_dependencies | ||
run_report | ||
} | ||
|
||
main |
2 changes: 1 addition & 1 deletion
2
source/documentation/adrs/000-record-architecture-decisions.html.md.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
source/documentation/adrs/004-use-aws-codepiplines-for-cicd.html.md.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
source/documentation/adrs/011-use-github-actions-for-ci-cd.html.md.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.