Skip to content

Commit 7b9fb9c

Browse files
author
Alex Plischke
authored
ci: bucket based previews (#2918)
1 parent f696960 commit 7b9fb9c

File tree

1 file changed

+37
-4
lines changed

1 file changed

+37
-4
lines changed

.github/workflows/deploy-pr-preview.yml

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,25 @@ jobs:
3535
node-version-file: '.nvmrc'
3636
cache: 'npm'
3737

38+
- name: Setup Python
39+
uses: actions/setup-python@v5
40+
with:
41+
python-version: '3.12'
42+
43+
- name: Google Cloud Login
44+
uses: google-github-actions/auth@v2
45+
with:
46+
credentials_json: '${{ secrets.RUN_SA_KEY_DEV }}'
47+
48+
- name: Setup Google Cloud SDK
49+
uses: google-github-actions/setup-gcloud@v2
50+
with:
51+
project_id: ${{ secrets.RUN_PROJECT_DEV }}
52+
env:
53+
CLOUDSDK_PYTHON: ${{ env.pythonLocation }}/python
54+
3855
- name: Set Preview Path
39-
run: echo "PREVIEW_PATH=sauce-docs/pr-preview/pr-${{ github.event.number }}" >> "$GITHUB_ENV"
56+
run: echo "PREVIEW_PATH=pr-preview/pr-${{ github.event.number }}" >> "$GITHUB_ENV"
4057

4158
- name: Install Dependencies
4259
if: github.event.action != 'closed' # Skip if the PR was closed
@@ -48,7 +65,23 @@ jobs:
4865
run: |
4966
npm run build
5067
51-
- name: Deploy PR
52-
uses: rossjrw/pr-preview-action@v1
68+
- name: Deploy
69+
if: github.event.action != 'closed' # Skip if the PR was closed
70+
working-directory: build
71+
run: |-
72+
gsutil -m rsync -R -d . ${{ secrets.GCS_DEV_BUCKET }}/${{ env.PREVIEW_PATH }}
73+
74+
- name: Deploy Message
75+
if: github.event.action != 'closed' # Skip if the PR was closed
76+
uses: unsplash/comment-on-pr@master
77+
env:
78+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5379
with:
54-
source-dir: ./build/
80+
msg: |
81+
Deploy preview ready for ${{ github.event.number }}!
82+
https://docs.dev.saucelabs.net/${{ env.PREVIEW_PATH }}
83+
84+
- name: Cleanup
85+
if: github.event.action == 'closed' # Cleanup action only on PR closure
86+
run: |-
87+
gsutil rm -r ${{ secrets.GCS_DEV_BUCKET }}/${{ env.PREVIEW_PATH }}

0 commit comments

Comments
 (0)