-
-
Notifications
You must be signed in to change notification settings - Fork 249
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Version selection: add AWS redirect configs for latest docs version (#…
…561) Co-authored-by: Matías García Isaía <[email protected]> Co-authored-by: Johannes Müller <[email protected]>
- Loading branch information
1 parent
7aff793
commit f79332d
Showing
4 changed files
with
101 additions
and
19 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
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,29 @@ | ||
name: Deploy config | ||
on: | ||
- create | ||
- workflow_dispatch | ||
|
||
jobs: | ||
build: | ||
name: Deploy config | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Download source | ||
uses: actions/checkout@v2 | ||
- name: Build versions files | ||
run: | | ||
scripts/docs-versions.sh origin | ||
grep '' versions.json aws-config.json # Display the files | ||
- name: Configure AWS Credentials | ||
if: github.repository == 'crystal-lang/crystal-book' | ||
uses: aws-actions/configure-aws-credentials@v1 | ||
with: | ||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
aws-region: us-east-1 | ||
- name: Deploy versions.json | ||
if: github.repository == 'crystal-lang/crystal-book' | ||
run: aws s3 cp versions.json 's3://crystal-book/reference/versions.json' | ||
- name: Deploy website configuration | ||
if: github.repository == 'crystal-lang/crystal-book' | ||
run: aws s3api put-bucket-website --bucket 'crystal-book' --website-configuration 'file://aws-config.json' |
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,52 @@ | ||
{ | ||
"IndexDocument": { | ||
"Suffix": "index.html" | ||
}, | ||
"RoutingRules": [ | ||
{ | ||
"Condition": { | ||
"KeyPrefixEquals": "reference/installation" | ||
}, | ||
"Redirect": { | ||
"HostName": "crystal-lang.org", | ||
"HttpRedirectCode": "301", | ||
"Protocol": "https", | ||
"ReplaceKeyPrefixWith": "install" | ||
} | ||
}, | ||
{ | ||
"Condition": { | ||
"KeyPrefixEquals": "reference/latest/${LATEST_VERSION}/" | ||
}, | ||
"Redirect": { | ||
"HostName": "crystal-lang.org", | ||
"HttpRedirectCode": "302", | ||
"Protocol": "https", | ||
"ReplaceKeyWith": "reference/${LATEST_VERSION}/404.html" | ||
} | ||
}, | ||
{ | ||
"Condition": { | ||
"KeyPrefixEquals": "reference/latest/" | ||
}, | ||
"Redirect": { | ||
"HostName": "crystal-lang.org", | ||
"HttpRedirectCode": "302", | ||
"Protocol": "https", | ||
"ReplaceKeyPrefixWith": "reference/${LATEST_VERSION}/" | ||
} | ||
}, | ||
{ | ||
"Condition": { | ||
"HttpErrorCodeReturnedEquals": "404", | ||
"KeyPrefixEquals": "reference/" | ||
}, | ||
"Redirect": { | ||
"HostName": "crystal-lang.org", | ||
"HttpRedirectCode": "301", | ||
"Protocol": "https", | ||
"ReplaceKeyPrefixWith": "reference/latest/" | ||
} | ||
} | ||
] | ||
} |
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,12 +1,19 @@ | ||
#!/usr/bin/env sh | ||
set -e | ||
#!/bin/bash | ||
set -eu | ||
|
||
printf '[' | ||
latest='"latest"' | ||
for ver in $(git ls-remote --heads "${1:-.}" | grep -P -o '(?<=refs/heads/release/)[0-9][0-9.]+' | sort -V -r); do | ||
printf '{"version": "%s", "title": "%s", "aliases": [%s]}, ' "$ver" "$ver" "$latest" | ||
latest='' | ||
done | ||
printf '{"version": "master", "title": "nightly", "aliases": []}' | ||
printf ']' | ||
test -z "$latest" # Check that we wrote at least one version | ||
branches=( $(git ls-remote --heads "${1:-.}" | grep -P -o '(?<=refs/heads/release/)[0-9][0-9.]+' | sort -V -r) ) | ||
latest_version="${branches[0]}" | ||
|
||
{ | ||
printf '[\n' | ||
latest='"latest"' | ||
for ver in "${branches[@]}"; do | ||
printf '{"version": "%s", "title": "%s", "aliases": [%s]},\n' "$ver" "$ver" "$latest" | ||
latest='' | ||
done | ||
printf '{"version": "master", "title": "nightly", "aliases": []}\n' | ||
printf ']\n' | ||
test -z "$latest" # Check that we wrote at least one version | ||
} > versions.json | ||
|
||
sed 's/\${LATEST_VERSION}/'"${latest_version}"'/g' "$(dirname "$0")/aws-config.json" > aws-config.json |