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
0 commit comments