Deploy to Production #3882
This file contains 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
name: Deploy to Production | |
on: | |
push: | |
branches: | |
- main | |
paths-ignore: | |
- '.github/**' | |
- '.docsearch/**' | |
- 'README.md' | |
- '.gitpod.yml' | |
workflow_dispatch: | |
env: | |
NO_INDEX: true | |
ALGOLIA_APP_ID: ${{secrets.ALGOLIA_APP_ID}} | |
ALGOLIA_KEY: ${{secrets.ALGOLIA_KEY}} | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
name: Checkout Repository | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-node@v4 | |
name: Setup Node.js | |
with: | |
node-version: 18.x | |
- uses: actions/cache@v4 | |
name: Cache NPM Packages | |
id: cache-npm-packages | |
with: | |
path: | | |
**/node_modules | |
key: ${{ runner.os }}-${{ hashFiles('**/package.json') }} | |
- name: Install Dependencies | |
if: steps.cache-npm-packages.outputs.cache-hit != 'true' | |
run: | | |
npm install | |
- uses: actions/cache@v4 | |
name: Cache Build | |
id: cache-build | |
with: | |
path: | | |
build | |
key: ${{ runner.os }}-${{ github.sha }} | |
- name: Run Build | |
if: steps.cache-build.outputs.cache-hit != 'true' | |
run: | | |
npm run build | |
deploy-staging: | |
needs: build | |
runs-on: ubuntu-latest | |
if: ${{ github.ref == 'refs/heads/main' }} | |
steps: | |
- uses: actions/checkout@v4 | |
name: Checkout Repository | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-node@v4 | |
name: Setup Node.js | |
with: | |
node-version: 18.x | |
- name: Install Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: 3.7 | |
- run: pip install crcmod | |
name: Install crcmod | |
- name: Set up Cloud SDK | |
uses: 'google-github-actions/setup-gcloud@v0' | |
with: | |
version: '290.0.1' | |
project_id: ${{ secrets.RUN_PROJECT }} | |
service_account_key: ${{ secrets.RUN_SA_KEY }} | |
- uses: actions/cache@v4 | |
name: Cache NPM Packages | |
id: cache-npm-packages | |
with: | |
path: | | |
**/node_modules | |
key: ${{ runner.os }}-${{ hashFiles('**/package.json') }} | |
- uses: actions/cache@v4 | |
name: Cache Build | |
id: cache-build | |
with: | |
path: | | |
build | |
key: ${{ runner.os }}-${{ github.sha }} | |
- name: Install Dependencies | |
if: steps.cache-npm-packages.outputs.cache-hit != 'true' | |
run: | | |
npm install | |
- name: Run Build | |
if: steps.cache-build.outputs.cache-hit != 'true' | |
run: | | |
npm run build | |
- name: Deploy to Bucket | |
run: |- | |
cd build | |
gsutil -m rsync -R -d . ${{ secrets.GCS_BUCKET }} | |
deploy-production: | |
needs: deploy-staging | |
runs-on: ubuntu-latest | |
if: ${{ github.ref == 'refs/heads/main' }} | |
env: | |
NO_INDEX: false | |
steps: | |
- uses: actions/checkout@v4 | |
name: Checkout Repository | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-node@v4 | |
name: Setup Node.js | |
with: | |
node-version: 18.x | |
- name: Install Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: 3.7 | |
- run: pip install crcmod | |
name: Install crcmod | |
- name: Set up Cloud SDK | |
uses: 'google-github-actions/setup-gcloud@v0' | |
with: | |
version: '290.0.1' | |
project_id: ${{ secrets.RUN_PROJECT_PROD }} | |
service_account_key: ${{ secrets.RUN_SA_KEY_PROD }} | |
- uses: actions/cache@v4 | |
name: Cache NPM Packages | |
id: cache-npm-packages | |
with: | |
path: | | |
**/node_modules | |
key: ${{ runner.os }}-${{ hashFiles('**/package.json') }} | |
- uses: actions/cache@v4 | |
name: Cache Build | |
id: cache-build | |
with: | |
path: | | |
build | |
key: ${{ runner.os }}-${{ github.sha }} | |
- name: Install Dependencies | |
if: steps.cache-build.outputs.cache-hit != 'true' | |
run: | | |
npm install | |
- name: Run Build | |
if: steps.cache-build.outputs.cache-hit != 'true' | |
run: | | |
npm run build | |
- name: Deploy to Bucket | |
run: |- | |
cd build | |
gsutil -m rsync -R -d . ${{ secrets.GCS_PROD_BUCKET }} |