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

chore(preview-envs): Build workflows to deploy and tear down preview … #3916

Closed
wants to merge 27 commits into from
Closed
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
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
61 changes: 61 additions & 0 deletions .github/workflows/preview-env-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: preview-env-deploy
on:
pull_request:

jobs:
deploy-preview:
#if: github.event.pull_request.state != 'closed' && (contains( github.event.label.name, 'deploy') || contains( github.event.pull_request.labels.*.name, 'deploy'))
runs-on: ubuntu-22.04
timeout-minutes: 40
name: deploy-preview-env-${{ matrix.product_context }}
steps:
- uses: actions/checkout@v2

- name: Import secrets
id: secrets
uses: hashicorp/vault-action@d1720f055e0635fd932a1d2a48f87a666a57906c
with:
url: ${{ secrets.VAULT_ADDR }}
method: approle
roleId: ${{ secrets.VAULT_ROLE_ID }}
secretId: ${{ secrets.VAULT_SECRET_ID }}
secrets: |
secret/data/products/camunda-docs/ci/preview-environment PREVIEW_ENV_BUCKET_NAME;
secret/data/products/camunda-docs/ci/preview-environment PREVIEW_ENV_GCLOUD_SA_KEY;
secret/data/products/camunda-docs/ci/preview-environment TEMP_BUCKET;
secret/data/products/camunda-docs/ci/preview-environment TEMP_SA;

- name: Install Dependencies
run: npm ci

- name: Build
run: npm run build
env:
NODE_OPTIONS: --max_old_space_size=8192

- name: Authenticate with Google Cloud
uses: google-github-actions/auth@v2
with:
credentials_json: ${{ steps.secrets.outputs.TEMP_SA }}

- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v2
with:
version: ">= 363.0.0"

- name: Upload files to google bucket
env:
BUCKET_NAME: ${{ steps.secrets.outputs.TEMP_BUCKET }}
run: |
andromaqui marked this conversation as resolved.
Show resolved Hide resolved
gcloud config set pass_credentials_to_gsutil true
gsutil -m cp -R . gs://$BUCKET_NAME/pr-${{ github.event.number }}/

- name: Create comment
uses: peter-evans/create-or-update-comment@v4
env:
BUCKET_NAME: ${{ steps.secrets.outputs.TEMP_BUCKET }}
with:
issue-number: ${{ github.event.number }}
body: |
Preview environment has successfully been deployed. You can access it on https://${{ env.BUCKET_NAME }}/pr-${{ github.event.number }}.
edit-mode: replace
54 changes: 54 additions & 0 deletions .github/workflows/preview-env-teardown.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: preview-env-deploy
on:
pull_request:
types: [labeled,synchronize]
andromaqui marked this conversation as resolved.
Show resolved Hide resolved

jobs:
deploy-preview:
if: github.event.pull_request.state != 'closed' && (contains( github.event.label.name, 'deploy') || contains( github.event.pull_request.labels.*.name, 'deploy'))
runs-on: ubuntu-22.04
timeout-minutes: 20
name: deploy-preview-env-${{ matrix.product_context }}
steps:
- uses: actions/checkout@v2

- name: Import secrets
id: secrets
uses: hashicorp/vault-action@d1720f055e0635fd932a1d2a48f87a666a57906c
with:
url: ${{ secrets.VAULT_ADDR }}
method: approle
roleId: ${{ secrets.VAULT_ROLE_ID }}
secretId: ${{ secrets.VAULT_SECRET_ID }}
secrets: |
secret/data/products/camunda-docs/ci/preview-environment PREVIEW_ENV_BUCKET_NAME;
secret/data/products/camunda-docs/ci/preview-environment PREVIEW_ENV_GCLOUD_SA_KEY;
secret/data/products/camunda-docs/ci/preview-environment TEMP_BUCKET;
secret/data/products/camunda-docs/ci/preview-environment TEMP_SA;

- name: Authenticate with Google Cloud
uses: google-github-actions/auth@v2
with:
credentials_json: ${{ steps.secrets.outputs.TEMP_SA }}

- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v2
with:
version: ">= 363.0.0"

- name: Upload files to google bucket
env:
BUCKET_NAME: ${{ steps.secrets.outputs.TEMP_BUCKET }}
run: |
andromaqui marked this conversation as resolved.
Show resolved Hide resolved
gcloud config set pass_credentials_to_gsutil true
gsutil -m rm -r gs://$BUCKET_NAME/pr-${{ github.event.number }}/

- name: Create comment
uses: peter-evans/create-or-update-comment@v4
env:
BUCKET_NAME: ${{ steps.secrets.outputs.TEMP_BUCKET }}
with:
issue-number: ${{ github.event.number }}
body: |
Your preview env has been teared down.
edit-mode: replace
4 changes: 2 additions & 2 deletions docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ module.exports = {
title: "Camunda 8 Docs",
tagline: "Documentation for all components of Camunda 8",
// url: "https://camunda-cloud.github.io",
url: "https://docs.camunda.io",
url: process.env.URL || "https://docs.camunda.io",
// baseUrl: "/camunda-cloud-documentation/",
baseUrl: "/",
baseUrl: process.env.BASE_URL || "/",
customFields: {
canonicalUrlRoot: "https://docs.camunda.io",
},
Expand Down
Loading