Skip to content

Commit 79b9f57

Browse files
committed
Merge branch 'main' into DOC-4898
2 parents 767f3f0 + d806d2a commit 79b9f57

File tree

58 files changed

+1334
-862
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+1334
-862
lines changed

.github/workflows/autocomment.yaml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,8 @@ jobs:
5151
$FILES_URL \
5252
| jq -r --arg prefix $BRANCH_NAME/ '.[] | select(((.filename | test("content\/.+\\.md")) and .status != "removed")) | ($prefix + .filename)' \
5353
| sed -E -e 's|(^[^/]+/)([^/]+/)|\1|' -e 's|^|https://redis.io/docs/staging/|' -e 's|(_?index)?\.md||' \
54-
| uniq \
55-
| xargs \
56-
| sed 's/ /<br>/g')
54+
| sort \
55+
| uniq)
5756
5857
# Get all changed image files
5958
CHANGED_IMAGE_FILES=$(curl -Ls \
@@ -70,14 +69,19 @@ jobs:
7069
for CHANGED_IMAGE_FILE in $CHANGED_IMAGE_FILES; do
7170
MD_FILE_WITH_IMAGE=$(grep -ro "$CHANGED_IMAGE_FILE" content \
7271
| sed -E -e 's|:.+||' -e "s|^content/|https://redis.io/docs/staging/$BRANCH_NAME/|" -e 's|(_?index)?\.md||' \
72+
| sort \
7373
| uniq)
7474
MD_FILES_WITH_IMAGE+=($MD_FILE_WITH_IMAGE)
7575
done
76-
CHANGED_MD_FILES_WITH_IMAGE=$(printf "%s\n" "${MD_FILES_WITH_IMAGE[@]}" \
76+
CHANGED_MD_FILES=$(printf "%s\n" "${CHANGED_MD_FILES}" "${MD_FILES_WITH_IMAGE[@]}" \
77+
| sort \
7778
| uniq \
7879
| xargs \
7980
| sed 's/ /<br>/g')
80-
CHANGED_MD_FILES="${CHANGED_MD_FILES}<br>${CHANGED_MD_FILES_WITH_IMAGE}"
81+
else
82+
CHANGED_MD_FILES=$(printf "%s\n" "${CHANGED_MD_FILES}" \
83+
| xargs \
84+
| sed 's/ /<br>/g')
8185
fi
8286
8387
if [[ -z "$CHANGED_MD_FILES" ]]
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: cleanup_pr_folders
2+
3+
on:
4+
pull_request:
5+
types:
6+
- closed
7+
8+
jobs:
9+
staging:
10+
if: github.event.pull_request.merged == true
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: 'read'
14+
id-token: 'write'
15+
env:
16+
STAGING_BUCKET: docs-staging-learn-redis-com
17+
STAGING_PROJECT_ID: ${{ secrets.GCP_PROJECT_STAGING }}
18+
STAGING_SERVICE_ACCOUNT: ${{ secrets.STAGING_SERVICE_ACCOUNT }}
19+
STAGING_WORKLOAD_IDENTITY_PROVIDER: ${{ secrets.STAGING_WORKLOAD_IDENTITY_PROVIDER }}
20+
21+
steps:
22+
- name: 'Google auth'
23+
uses: 'google-github-actions/auth@v2'
24+
with:
25+
project_id: '${{ env.STAGING_PROJECT_ID }}'
26+
service_account: '${{ env.STAGING_SERVICE_ACCOUNT }}'
27+
workload_identity_provider: '${{ env.STAGING_WORKLOAD_IDENTITY_PROVIDER }}'
28+
29+
- name: 'Set up Cloud SDK'
30+
uses: 'google-github-actions/setup-gcloud@v2'
31+
with:
32+
project_id: '${{ env.STAGING_PROJECT_ID }}'
33+
version: '>= 363.0.0'
34+
35+
- name: Remove pull request staging folder
36+
run: |
37+
BRANCH_TO_CLEANUP="${{ github.event.pull_request.head.ref }}"
38+
STAGING_BUCKET="${{ env.STAGING_BUCKET }}"
39+
40+
if gsutil -q stat gs://${STAGING_BUCKET}/staging/${BRANCH_TO_CLEANUP}/*; then
41+
gsutil -q -m rm -r gs://${STAGING_BUCKET}/staging/${BRANCH_TO_CLEANUP}/*
42+
echo "Removed gs://${STAGING_BUCKET}/staging/${BRANCH_TO_CLEANUP}"
43+
fi
44+
45+
prod:
46+
if: github.event.pull_request.merged == true
47+
runs-on: ubuntu-latest
48+
permissions:
49+
contents: 'read'
50+
id-token: 'write'
51+
env:
52+
PROD_BUCKET: docs-prod-learn-redis-com
53+
PROD_PROJECT_ID: ${{ secrets.GCP_PROJECT_PROD }}
54+
PROD_SERVICE_ACCOUNT: ${{ secrets.PROD_SERVICE_ACCOUNT }}
55+
PROD_WORKLOAD_IDENTITY_PROVIDER: ${{ secrets.PROD_WORKLOAD_IDENTITY_PROVIDER }}
56+
57+
steps:
58+
- name: 'Google auth'
59+
uses: 'google-github-actions/auth@v2'
60+
with:
61+
project_id: '${{ env.PROD_PROJECT_ID }}'
62+
service_account: '${{ env.PROD_SERVICE_ACCOUNT }}'
63+
workload_identity_provider: '${{ env.PROD_WORKLOAD_IDENTITY_PROVIDER }}'
64+
65+
- name: 'Set up Cloud SDK'
66+
uses: 'google-github-actions/setup-gcloud@v2'
67+
with:
68+
project_id: '${{ env.PROD_PROJECT_ID }}'
69+
version: '>= 363.0.0'
70+
71+
- name: Remove pull request staging folder
72+
run: |
73+
BRANCH_TO_CLEANUP="${{ github.event.pull_request.head.ref }}"
74+
PROD_BUCKET="${{ env.PROD_BUCKET }}"
75+
76+
if gsutil -q stat gs://${PROD_BUCKET}/staging/${BRANCH_TO_CLEANUP}/*; then
77+
gsutil -q -m rm -r gs://${PROD_BUCKET}/staging/${BRANCH_TO_CLEANUP}/*
78+
echo "Removed gs://${PROD_BUCKET}/staging/${BRANCH_TO_CLEANUP}"
79+
fi

.github/workflows/main-staging.yml

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,17 @@ jobs:
66
build_docs:
77
name: Build the staging documentation site
88
runs-on: ubuntu-latest
9+
permissions:
10+
contents: 'read'
11+
id-token: 'write'
912
env:
1013
HUGO_VERSION: 0.143.1
1114
GCLOUD_VERSION: 458.0.1-linux-x86_64
1215
BUCKET: docs-staging-learn-redis-com
13-
BUCKET_SERVICE_ACCOUNT: ${{ secrets.BUCKET_DOCUMENTATION_SA_STAGING }}
14-
BUCKET_SECRET: ${{ secrets.BUCKET_DOCUMENTATION_STAGING }}
15-
GCP_PROJECT: ${{ secrets.GCP_PROJECT_STAGING }}
16+
STAGING_PROJECT_ID: ${{ secrets.GCP_PROJECT_STAGING }}
17+
STAGING_SERVICE_ACCOUNT: ${{ secrets.STAGING_SERVICE_ACCOUNT }}
18+
STAGING_WORKLOAD_IDENTITY_PROVIDER: ${{ secrets.STAGING_WORKLOAD_IDENTITY_PROVIDER }}
19+
1620
steps:
1721
- name: Start
1822
run: echo "The name of the branch is ${{ github.ref }} on ${{ github.repository }}"
@@ -162,17 +166,20 @@ jobs:
162166
run: ls "${{ github.workspace }}/examples"
163167
- name: List files to be published
164168
run: ls "${{ github.workspace }}/public"
165-
- name: Install the Google Cloud CLI
166-
run: |
167-
wget -O ${{ github.workspace }}/google-cloud-cli.tar.gz "https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-cli-$GCLOUD_VERSION.tar.gz" \
168-
&& tar -xvf google-cloud-cli.tar.gz -C ${{ github.workspace }}\
169-
&& ${{ github.workspace }}/google-cloud-sdk/install.sh --quiet
170-
- name: Prepare bucket authentication
171-
run: echo $BUCKET_SECRET | base64 --decode > service_account.json && ls -a service_account.json
172-
- name: Authenticate to the bucket
173-
run: |
174-
./google-cloud-sdk/bin/gcloud auth activate-service-account $BUCKET_SERVICE_ACCOUNT --key-file=./service_account.json --project=$GCP_PROJECT \
175-
&& ./google-cloud-sdk/bin/gcloud auth list
169+
170+
- name: 'Google auth'
171+
uses: 'google-github-actions/auth@v2'
172+
with:
173+
project_id: '${{ env.STAGING_PROJECT_ID }}'
174+
service_account: '${{ env.STAGING_SERVICE_ACCOUNT }}'
175+
workload_identity_provider: '${{ env.STAGING_WORKLOAD_IDENTITY_PROVIDER }}'
176+
177+
- name: 'Set up Cloud SDK'
178+
uses: 'google-github-actions/setup-gcloud@v2'
179+
with:
180+
project_id: '${{ env.STAGING_PROJECT_ID }}'
181+
version: '>= 363.0.0'
182+
176183
- name: Sync the branch to the bucket
177184
run: |
178185
if [[ "${{ github.ref_name }}" == "main" ]]
@@ -187,7 +194,7 @@ jobs:
187194
else
188195
bucket_path=staging/${{ github.ref_name }}
189196
fi \
190-
&& ./google-cloud-sdk/bin/gsutil -m rsync -r -c -j html -d ${{ github.workspace }}/public gs://$BUCKET/$bucket_path
197+
&& gsutil -m rsync -r -c -j html -d ${{ github.workspace }}/public gs://$BUCKET/$bucket_path
191198
192199
versioned_builds=($(find . -type d -regex ".*[0-9-]" -maxdepth 1 | sed -E 's/^.\///'))
193200
for versioned_build in "${versioned_builds[@]}"; do

.github/workflows/main.yml

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,17 @@ jobs:
66
build_docs:
77
name: Build the production documentation site
88
runs-on: ubuntu-latest
9+
permissions:
10+
contents: 'read'
11+
id-token: 'write'
912
env:
1013
HUGO_VERSION: 0.143.1
1114
GCLOUD_VERSION: 458.0.1-linux-x86_64
1215
BUCKET: docs-prod-learn-redis-com
13-
BUCKET_SERVICE_ACCOUNT: ${{ secrets.BUCKET_DOCUMENTATION_SA_PROD }}
14-
BUCKET_SECRET: ${{ secrets.BUCKET_DOCUMENTATION_PROD }}
15-
GCP_PROJECT: ${{ secrets.GCP_PROJECT_PROD }}
16+
PROD_PROJECT_ID: ${{ secrets.GCP_PROJECT_PROD }}
17+
PROD_SERVICE_ACCOUNT: ${{ secrets.PROD_SERVICE_ACCOUNT }}
18+
PROD_WORKLOAD_IDENTITY_PROVIDER: ${{ secrets.PROD_WORKLOAD_IDENTITY_PROVIDER }}
19+
1620
steps:
1721
- name: Start
1822
run: echo "The name of the branch is ${{ github.ref }} on ${{ github.repository }}"
@@ -162,17 +166,20 @@ jobs:
162166
run: ls "${{ github.workspace }}/examples"
163167
- name: List files to be published
164168
run: ls "${{ github.workspace }}/public"
165-
- name: Install the Google Cloud CLI
166-
run: |
167-
wget -O ${{ github.workspace }}/google-cloud-cli.tar.gz "https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-cli-$GCLOUD_VERSION.tar.gz" \
168-
&& tar -xvf google-cloud-cli.tar.gz -C ${{ github.workspace }}\
169-
&& ${{ github.workspace }}/google-cloud-sdk/install.sh --quiet
170-
- name: Prepare bucket authentication
171-
run: echo $BUCKET_SECRET | base64 --decode > service_account.json && ls -a service_account.json
172-
- name: Authenticate to the bucket
173-
run: |
174-
./google-cloud-sdk/bin/gcloud auth activate-service-account $BUCKET_SERVICE_ACCOUNT --key-file=./service_account.json --project=$GCP_PROJECT \
175-
&& ./google-cloud-sdk/bin/gcloud auth list
169+
170+
- name: 'Google auth'
171+
uses: 'google-github-actions/auth@v2'
172+
with:
173+
project_id: '${{ env.PROD_PROJECT_ID }}'
174+
service_account: '${{ env.PROD_SERVICE_ACCOUNT }}'
175+
workload_identity_provider: '${{ env.PROD_WORKLOAD_IDENTITY_PROVIDER }}'
176+
177+
- name: 'Set up Cloud SDK'
178+
uses: 'google-github-actions/setup-gcloud@v2'
179+
with:
180+
project_id: '${{ env.PROD_PROJECT_ID }}'
181+
version: '>= 363.0.0'
182+
176183
- name: Sync the branch to the bucket
177184
run: |
178185
if [[ "${{ github.ref_name }}" == "main" ]]
@@ -187,7 +194,7 @@ jobs:
187194
else
188195
bucket_path=staging/${{ github.ref_name }}
189196
fi \
190-
&& ./google-cloud-sdk/bin/gsutil -m rsync -r -c -j html -d ${{ github.workspace }}/public gs://$BUCKET/$bucket_path
197+
&& gsutil -m rsync -r -c -j html -d ${{ github.workspace }}/public gs://$BUCKET/$bucket_path
191198
192199
if [[ "${{ github.ref_name }}" == "latest" ]]
193200
then

.github/workflows/test_gcs_access.yml

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,36 @@ jobs:
77
test_gcs:
88
name: Test Google Cloud Storage access
99
runs-on: ubuntu-latest
10+
permissions:
11+
contents: 'read'
12+
id-token: 'write'
1013
env:
1114
GCLOUD_VERSION: 458.0.1-linux-x86_64
1215
BUCKET: docs-prod-learn-redis-com
13-
BUCKET_SERVICE_ACCOUNT: ${{ secrets.BUCKET_DOCUMENTATION_SA_PROD }}
14-
BUCKET_SECRET: ${{ secrets.BUCKET_DOCUMENTATION_PROD }}
15-
GCP_PROJECT: ${{ secrets.GCP_PROJECT_PROD }}
16+
PROD_PROJECT_ID: ${{ secrets.GCP_PROJECT_PROD }}
17+
PROD_SERVICE_ACCOUNT: ${{ secrets.PROD_SERVICE_ACCOUNT }}
18+
PROD_WORKLOAD_IDENTITY_PROVIDER: ${{ secrets.PROD_WORKLOAD_IDENTITY_PROVIDER }}
19+
1620
steps:
1721
- uses: actions/checkout@v4
1822
- name: Start
1923
run: echo "The name of the branch is ${{ github.ref }} on ${{ github.repository }}"
20-
- name: Fetch the credentails
21-
run: echo $BUCKET_SECRET | base64 --decode > service_account.json && ls -a service_account.json
22-
- name: Install the Google Cloud CLI
23-
run: |
24-
wget -O ${{ github.workspace }}/google-cloud-cli.tar.gz "https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-cli-$GCLOUD_VERSION.tar.gz" \
25-
&& tar -xvf google-cloud-cli.tar.gz -C ${{ github.workspace }}\
26-
&& ${{ github.workspace }}/google-cloud-sdk/install.sh --quiet
27-
- name: Authenticate to Google Cloud
28-
run: |
29-
./google-cloud-sdk/bin/gcloud auth activate-service-account $BUCKET_SERVICE_ACCOUNT --key-file=./service_account.json --project=$GCP_PROJECT \
30-
&& ./google-cloud-sdk/bin/gcloud auth list
24+
25+
- name: 'Google auth'
26+
uses: 'google-github-actions/auth@v2'
27+
with:
28+
project_id: '${{ env.PROD_PROJECT_ID }}'
29+
service_account: '${{ env.PROD_SERVICE_ACCOUNT }}'
30+
workload_identity_provider: '${{ env.PROD_WORKLOAD_IDENTITY_PROVIDER }}'
31+
32+
- name: 'Set up Cloud SDK'
33+
uses: 'google-github-actions/setup-gcloud@v2'
34+
with:
35+
project_id: '${{ env.PROD_PROJECT_ID }}'
36+
version: '>= 363.0.0'
37+
3138
- name: List files
32-
run: ./google-cloud-sdk/bin/gsutil ls gs://$BUCKET
39+
run: gsutil ls gs://$BUCKET
3340
- name: End
3441
run: echo "This job's status is ${{ job.status }}."
3542

0 commit comments

Comments
 (0)