Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: bucket based previews #2918

Merged
merged 3 commits into from
Aug 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 37 additions & 4 deletions .github/workflows/deploy-pr-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,25 @@ jobs:
node-version-file: '.nvmrc'
cache: 'npm'

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Google Cloud Login
uses: google-github-actions/auth@v2
with:
credentials_json: '${{ secrets.RUN_SA_KEY_DEV }}'

- name: Setup Google Cloud SDK
uses: google-github-actions/setup-gcloud@v2
with:
project_id: ${{ secrets.RUN_PROJECT_DEV }}
env:
CLOUDSDK_PYTHON: ${{ env.pythonLocation }}/python

- name: Set Preview Path
run: echo "PREVIEW_PATH=sauce-docs/pr-preview/pr-${{ github.event.number }}" >> "$GITHUB_ENV"
run: echo "PREVIEW_PATH=pr-preview/pr-${{ github.event.number }}" >> "$GITHUB_ENV"

- name: Install Dependencies
if: github.event.action != 'closed' # Skip if the PR was closed
Expand All @@ -48,7 +65,23 @@ jobs:
run: |
npm run build

- name: Deploy PR
uses: rossjrw/pr-preview-action@v1
- name: Deploy
if: github.event.action != 'closed' # Skip if the PR was closed
working-directory: build
run: |-
gsutil -m rsync -R -d . ${{ secrets.GCS_DEV_BUCKET }}/${{ env.PREVIEW_PATH }}

- name: Deploy Message
if: github.event.action != 'closed' # Skip if the PR was closed
uses: unsplash/comment-on-pr@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
source-dir: ./build/
msg: |
Deploy preview ready for ${{ github.event.number }}!
https://docs.dev.saucelabs.net/${{ env.PREVIEW_PATH }}

- name: Cleanup
if: github.event.action == 'closed' # Cleanup action only on PR closure
run: |-
gsutil rm -r ${{ secrets.GCS_DEV_BUCKET }}/${{ env.PREVIEW_PATH }}