chore(preview-envs): Build workflows to deploy and tear down preview … #26
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: preview-env-deploy | ||
on: | ||
pull_request: | ||
types: [labeled, synchronize] | ||
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 | ||
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 | ||
URL: https://somebucket | ||
BASE_URL: /pr-${{ github.event.number }} | ||
- 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" | ||
- uses: bobheadxi/deployments@v1 | ||
id: deployment | ||
with: | ||
step: start | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
env: ${{ github.event.number }} | ||
- name: Upload files to google bucket | ||
env: | ||
BUCKET_NAME: ${{ steps.secrets.outputs.TEMP_BUCKET }} | ||
run: | | ||
gcloud config set pass_credentials_to_gsutil true | ||
gsutil -m cp -R build/* gs://$BUCKET_NAME/pr-${{ github.event.number }}/index.html | ||
- uses: bobheadxi/deployments@v1 | ||
id: deployment | ||
Check failure on line 64 in .github/workflows/preview-env-deploy.yml GitHub Actions / preview-env-deployInvalid workflow file
|
||
with: | ||
step: finish | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
status: ${{ job.status }} | ||
env: ${{ steps.deployment.outputs.env }} | ||
deployment_id: ${{ steps.deployment.outputs.deployment_id }} | ||
- 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 |