Skip to content

Commit

Permalink
deploy changes again
Browse files Browse the repository at this point in the history
  • Loading branch information
andromaqui committed Jun 20, 2024
1 parent b736ba9 commit 68ab9c4
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 34 deletions.
67 changes: 34 additions & 33 deletions .github/workflows/preview-env-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ on:
pull_request:
types: [labeled, synchronize]

concurrency:
cancel-in-progress: true
group: ${{ github.workflow }}

jobs:
deploy-preview:
if: github.event.pull_request.state != 'closed' && (contains( github.event.label.name, 'deploy') || contains( github.event.pull_request.labels.*.name, 'deploy'))
Expand All @@ -24,18 +28,18 @@ jobs:
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;
- name: Find deployment comment
uses: peter-evans/find-comment@v1
id: find-deployment-comment
env:
BUCKET_NAME: ${{ steps.secrets.outputs.PREVIEW_ENV_BUCKET_NAME }}
with:
issue-number: ${{ github.event.number }}
body-includes: Preview environment has successfully been deployed. You can access it on https://${{ env.BUCKET_NAME }}/pr-${{ github.event.number }}/index.html.

- name: Install Dependencies
run: npm ci

- name: start deployment
uses: bobheadxi/deployments@v1
id: deployment
with:
step: start
token: "${{ github.token }}"
env: ${{ github.event.repository.name }}
ref: ${{ github.event.pull_request.head.sha }}

- name: Build
env:
NODE_OPTIONS: --max_old_space_size=8192
Expand All @@ -51,31 +55,12 @@ jobs:
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v2

- name: start deployment
uses: bobheadxi/deployments@v1
id: deployment
with:
step: start
token: "${{ github.token }}"
env: ${{ github.event.repository.name }}
ref: ${{ github.event.pull_request.head.sha }}

# If the deployment comment is found, remove the old static files from the bucket
# before uploading the new build
- name: Remove files from Google bucket from previous deployment
if: steps.find-deployment-comment.outputs.comment-id != ''
env:
BUCKET_NAME: ${{ steps.secrets.outputs.PREVIEW_ENV_BUCKET_NAME }}
run: |
gcloud config set pass_credentials_to_gsutil true
gsutil -m rm -r gs://$BUCKET_NAME/pr-${{ github.event.number }}/
- name: Upload files to google bucket
env:
BUCKET_NAME: ${{ steps.secrets.outputs.PREVIEW_ENV_BUCKET_NAME }}
run: |
gcloud config set pass_credentials_to_gsutil true
gsutil -m cp -R build/* gs://$BUCKET_NAME/pr-${{ github.event.number }}
gsutil -m rsync -d -r build gs://$BUCKET_NAME/pr-${{ github.event.number }}
- uses: bobheadxi/deployments@v1
with:
Expand All @@ -84,6 +69,11 @@ jobs:
status: ${{ job.status }}
env: ${{ steps.deployment.outputs.env }}
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
env_url: https://${{ steps.secrets.outputs.PREVIEW_ENV_BUCKET_NAME }}/pr-${{ github.event.number }}/index.html

- name: Short commit SHA
id: extract_sha
run: echo "short_sha=$(echo ${{ github.sha }} | cut -c1-10)" >> $GITHUB_ENV

- name: Find env tear down comment
uses: peter-evans/find-comment@v1
Expand All @@ -95,19 +85,30 @@ jobs:
- name: Update env tear down comment
if: steps.find-teardown-comment.outputs.comment-id != ''
uses: peter-evans/create-or-update-comment@v4
env:
BUCKET_NAME: ${{ steps.secrets.outputs.PREVIEW_ENV_BUCKET_NAME }}
with:
comment-id: ${{ steps.find-teardown-comment.outputs.comment-id }}
body: |
Your preview env has been torn down.
The preview environment relating to the commit ${{ env.short_sha }} has successfully been deployed. You can access it on https://${{ env.BUCKET_NAME }}/pr-${{ github.event.number }}/index.html.
edit-mode: replace

- name: Create comment
if: steps.find-deployment-comment.outputs.comment-id == ''
- name: Find deployment comment
uses: peter-evans/find-comment@v1
id: find-deployment-comment
env:
BUCKET_NAME: ${{ steps.secrets.outputs.PREVIEW_ENV_BUCKET_NAME }}
with:
issue-number: ${{ github.event.number }}
body-includes: Preview environment has successfully been deployed. You can access it on https://${{ env.BUCKET_NAME }}/pr-${{ github.event.number }}/index.html.

- name: Upsert deployment comment
if: steps.find-deployment-comment.outputs.comment-id == '' && steps.find-teardown-comment.outputs.comment-id == ''
uses: peter-evans/create-or-update-comment@v4
env:
BUCKET_NAME: ${{ steps.secrets.outputs.PREVIEW_ENV_BUCKET_NAME }}
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 }}/index.html.
The preview environment relating to the commit ${{ env.short_sha }} has successfully been deployed. You can access it on https://${{ env.BUCKET_NAME }}/pr-${{ github.event.number }}/index.html.
edit-mode: replace
2 changes: 1 addition & 1 deletion .github/workflows/preview-env-teardown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
BUCKET_NAME: ${{ steps.secrets.outputs.PREVIEW_ENV_BUCKET_NAME }}
with:
issue-number: ${{ github.event.number }}
body-includes: Preview environment has successfully been deployed. You can access it on https://${{ env.BUCKET_NAME }}/pr-${{ github.event.number }}/index.html.
body-includes: The preview environment relating to the commit

- name: Update comment
if: steps.find-comment.outputs.comment-id != ''
Expand Down

0 comments on commit 68ab9c4

Please sign in to comment.