DOC-5192 added C# production usage page #5480
This file contains hidden or 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
on: | |
push: | |
branches: | |
- '**' | |
jobs: | |
build_docs: | |
name: Build the staging documentation site | |
runs-on: ubuntu-latest | |
permissions: | |
contents: 'read' | |
id-token: 'write' | |
env: | |
HUGO_VERSION: 0.143.1 | |
GCLOUD_VERSION: 458.0.1-linux-x86_64 | |
BUCKET: docs-staging-learn-redis-com | |
STAGING_PROJECT_ID: ${{ secrets.GCP_PROJECT_STAGING }} | |
STAGING_SERVICE_ACCOUNT: ${{ secrets.STAGING_SERVICE_ACCOUNT }} | |
STAGING_WORKLOAD_IDENTITY_PROVIDER: ${{ secrets.STAGING_WORKLOAD_IDENTITY_PROVIDER }} | |
steps: | |
- name: Start | |
run: echo "The name of the branch is ${{ github.ref }} on ${{ github.repository }}" | |
- name: Install Hugo | |
run: | | |
wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb \ | |
&& sudo dpkg -i ${{ runner.temp }}/hugo.deb | |
- name: Check the branch out | |
uses: actions/checkout@v4 | |
- name: List repository files | |
run: ls ${{ github.workspace }} | |
- name: Validate the branch name before using it | |
run: | | |
if [[ "${{ github.ref_name }}" =~ ^[a-zA-Z0-9_.-]+$ ]] | |
then | |
echo "The branch name ${{ github.ref_name }} is valid." | |
else | |
echo "ERROR: Invalid branch name ${{ github.ref_name }}!" | |
exit 1 | |
fi | |
- name: Install dependencies | |
run: make deps | |
- name: Build out all versions | |
run: | | |
set -x | |
function setBaseUrl() { | |
if [[ "${{ github.ref_name }}" == "main" ]] | |
then | |
hugo_root_path=docs/staging/dev | |
elif [[ "${{ github.ref_name }}" == "latest" ]] | |
then | |
hugo_root_path="docs/latest" | |
elif [[ "${{ endsWith(github.ref_name, '-build') }}" == "true" ]] | |
then | |
hugo_root_path=`echo docs/version/${{ github.ref_name }} | sed 's/-build$//'` | |
else | |
hugo_root_path=docs/staging/${{ github.ref_name }} | |
fi \ | |
&& sed -i "s#baseURL = \"https://redis.io\"#baseURL = \"https://redis.io/$hugo_root_path\"#g" config.toml | |
} | |
setBaseUrl | |
kubernetes_versions=($(find content/operate/kubernetes/ -maxdepth 1 -type d -regex ".*[0-9-]" | awk -F/ '{print $NF}')) | |
rs_versions=($(find content/operate/rs/ -maxdepth 1 -type d -regex ".*[0-9-]" | awk -F/ '{print $NF}')) | |
rdi_versions=($(find content/integrate/redis-data-integration/ -maxdepth 1 -type d -regex ".*[0-9-]" | awk -F/ '{print $NF}')) | |
# build latest | |
for version in "${kubernetes_versions[@]}"; do | |
rm -r "content/operate/kubernetes/${version}" | |
done | |
for version in "${rs_versions[@]}"; do | |
rm -r "content/operate/rs/${version}" | |
done | |
for version in "${rdi_versions[@]}"; do | |
rm -r "content/integrate/redis-data-integration/${version}" | |
done | |
make all | |
git checkout . | |
# build all versions | |
for version in "${kubernetes_versions[@]}"; do | |
setBaseUrl | |
# for each version, remove all other versions before building | |
versions_to_remove=($(echo "${kubernetes_versions[@]}" "${version}" | tr ' ' '\n' | sort | uniq -u)) | |
for version_to_remove in "${versions_to_remove[@]}"; do | |
rm -r "content/operate/kubernetes/${version_to_remove}" | |
done | |
# relrefs should not include version | |
find "content/operate/kubernetes/${version}" -type f | while read file; do | |
awk '{gsub(/\(\{\{< ?relref "\/operate\/kubernetes\/'${version}'/, "({{< relref \"/operate/kubernetes") }1' "$file" > tmpfile && mv tmpfile "$file" | |
done | |
rsync -a --delete-after "content/operate/kubernetes/${version}"/ content/operate/kubernetes/ | |
sed -i 's/id="versionSelectorKubernetesValue" class="version-selector-control">latest/id="versionSelectorKubernetesValue" class="version-selector-control">v'"${version}"'/' layouts/partials/docs-nav.html | |
sed -i 's/linkTitle: '"${version}"'/linkTitle: Redis for Kubernetes/' content/operate/kubernetes/_index.md | |
# inject replace command in meta-links to make sure editURL and issuesURL point to right version | |
sed -i "12i \{\{ \$gh_path = replaceRE \`\^operate\/kubernetes\/\` \"operate\/kubernetes\/$version\/\" \$gh_path }}" layouts/partials/meta-links.html | |
hugo -d "kubernetes-${version}" | |
git checkout . | |
done | |
for version in "${rs_versions[@]}"; do | |
setBaseUrl | |
# for each version, remove all other versions before building | |
versions_to_remove=($(echo "${rs_versions[@]}" "${version}" | tr ' ' '\n' | sort | uniq -u)) | |
for version_to_remove in "${versions_to_remove[@]}"; do | |
rm -r "content/operate/rs/${version_to_remove}" | |
done | |
# relrefs should not include version | |
find "content/operate/rs/${version}" -type f | while read file; do | |
awk '{gsub(/\(\{\{< ?relref "\/operate\/rs\/'${version}'/, "({{< relref \"/operate/rs") }1' "$file" > tmpfile && mv tmpfile "$file" | |
done | |
rsync -a --delete-after "content/operate/rs/${version}"/ content/operate/rs/ | |
sed -i 's/id="versionSelectorRsValue" class="version-selector-control">latest/id="versionSelectorRsValue" class="version-selector-control">v'"${version}"'/' layouts/partials/docs-nav.html | |
sed -i 's/linkTitle: '"${version}"'/linkTitle: Redis Software/' content/operate/rs/_index.md | |
# inject replace command in meta-links to make sure editURL and issuesURL point to right version | |
sed -i "12i \{\{ \$gh_path = replaceRE \`\^operate\/rs\/\` \"operate\/rs\/$version\/\" \$gh_path }}" layouts/partials/meta-links.html | |
hugo -d "rs-${version}" | |
git checkout . | |
done | |
for version in "${rdi_versions[@]}"; do | |
setBaseUrl | |
# for each version, remove all other versions before building | |
versions_to_remove=($(echo "${rdi_versions[@]}" "${version}" | tr ' ' '\n' | sort | uniq -u)) | |
for version_to_remove in "${versions_to_remove[@]}"; do | |
rm -r "content/integrate/redis-data-integration/${version_to_remove}" | |
done | |
# relrefs should not include version | |
find "content/operate/redis-data-integration/${version}" -type f | while read file; do | |
awk '{gsub(/\(\{\{< ?relref "\/operate\/redis-data-integration\/'${version}'/, "({{< relref \"/operate/redis-data-integration") }1' "$file" > tmpfile && mv tmpfile "$file" | |
done | |
rsync -a --delete-after "content/operate/redis-data-integration/${version}"/ content/operate/redis-data-integration/ | |
sed -i 's/id="versionSelectorRedis-Data-IntegrationValue" class="version-selector-control">latest/id="versionSelectorRedis-Data-IntegrationValue" class="version-selector-control">v'"${version}"'/' layouts/partials/docs-nav.html | |
sed -i 's/linkTitle: '"${version}"'/linkTitle: Redis Data Integration/' content/integrate/redis-data-integration/_index.md | |
# inject replace command in meta-links to make sure editURL and issuesURL point to right version | |
sed -i "12i \{\{ \$gh_path = replaceRE \`\^integrate\/redis-data-integration\/\` \"integrate\/redis-data-integration\/$version\/\" \$gh_path }}" layouts/partials/meta-links.html | |
hugo -d "redis-data-integration-${version}" | |
git checkout . | |
done | |
- name: List client examples | |
run: ls "${{ github.workspace }}/examples" | |
- name: List files to be published | |
run: ls "${{ github.workspace }}/public" | |
- name: 'Google auth' | |
uses: 'google-github-actions/auth@v2' | |
with: | |
project_id: '${{ env.STAGING_PROJECT_ID }}' | |
service_account: '${{ env.STAGING_SERVICE_ACCOUNT }}' | |
workload_identity_provider: '${{ env.STAGING_WORKLOAD_IDENTITY_PROVIDER }}' | |
- name: 'Set up Cloud SDK' | |
uses: 'google-github-actions/setup-gcloud@v2' | |
with: | |
project_id: '${{ env.STAGING_PROJECT_ID }}' | |
version: '>= 363.0.0' | |
- name: Sync the branch to the bucket | |
run: | | |
if [[ "${{ github.ref_name }}" == "main" ]] | |
then | |
bucket_path=staging/dev | |
elif [[ "${{ github.ref_name }}" == "latest" ]] | |
then | |
bucket_path=${{ github.ref_name }} | |
elif [[ "${{ endsWith(github.ref_name, '-build') }}" == "true" ]] | |
then | |
bucket_path=`echo "version/${{ github.ref_name }}" | sed 's/-build$//'` | |
else | |
bucket_path=staging/${{ github.ref_name }} | |
fi \ | |
&& gsutil -m rsync -r -c -j html -d ${{ github.workspace }}/public gs://$BUCKET/$bucket_path | |
versioned_builds=($(find . -type d -regex ".*[0-9-]" -maxdepth 1 | sed -E 's/^.\///')) | |
for versioned_build in "${versioned_builds[@]}"; do | |
product=$(awk 'BEGIN{FS=OFS="-"}{NF--; print}' <<< $versioned_build) | |
if [[ "${product}" == "redis-data-integration" ]]; then | |
gsutil -m rsync -r -c -j html -d "${{ github.workspace }}/${versioned_build}/integrate/${product}/" "gs://${BUCKET}/${bucket_path}/${versioned_build}/integrate/${product}" | |
else | |
gsutil -m rsync -r -c -j html -d "${{ github.workspace }}/${versioned_build}/operate/${product}/" "gs://${BUCKET}/${bucket_path}/${versioned_build}/operate/${product}" | |
fi | |
done | |
- name: End | |
run: echo "This job's status is ${{ job.status }}." |