-
Notifications
You must be signed in to change notification settings - Fork 109
56 lines (56 loc) · 2.75 KB
/
DEPLOY_PLAYGROUND_PREVIEW.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
name: Deploy playground preview
on:
pull_request:
types: [labeled, synchronize]
jobs:
deploy-preview:
# check whether the labeled event was deploy-preview || check whether on new commit of PR the label deploy-preview exists
if: github.event.label.name == 'deploy-preview' || contains( github.event.pull_request.labels.*.name, 'deploy-preview')
runs-on: ubuntu-latest
env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }} # head_ref = branch on PR, ref_name if main / stable/**
steps:
- id: sanitize
name: Sanitize form-playground branch name
uses: camunda/infra-global-github-actions/sanitize-branch-name@main
with:
branch: ${{ env.BRANCH_NAME }}
max_length: '25'
- name: Save form-playground branch name
run: echo "PREVIEW_BRANCH_NAME=demo-${{ steps.sanitize.outputs.branch_name }}" >> $GITHUB_ENV
- name: Check form-playground branch
run: echo "BRANCH_EXISTS=$(git ls-remote --heads https://${{ secrets.ADD_TO_HTO_PROJECT_PAT }}@github.com./camunda/form-playground ${{ env.PREVIEW_BRANCH_NAME }} | wc -l)" >> $GITHUB_ENV
- name: Create form-playground branch
if: env.BRANCH_EXISTS == 0
uses: GuillaumeFalourd/create-other-repo-branch-action@706963eca4b230707b1cfecee6760b519e2cbbf3
with:
repository_owner: camunda
repository_name: form-playground
new_branch_name: ${{ env.PREVIEW_BRANCH_NAME }}
access_token: ${{ secrets.ADD_TO_HTO_PROJECT_PAT }}
- name: Create GitHub deployment
uses: bobheadxi/deployments@648679e8e4915b27893bd7dbc35cb504dc915bc8
id: deployment
with:
step: start
env: ${{ env.PREVIEW_BRANCH_NAME }}
token: ${{ secrets.GITHUB_TOKEN }}
ref: ${{ env.BRANCH_NAME }}
- name: Trigger Netlify branch build
run: |
curl --location --request POST '${{ secrets.NETLIFY_CUSTOM_BUILD_HOOK }}?trigger_branch=${{ env.PREVIEW_BRANCH_NAME }}&clear_cache=true' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'FORM_JS_BRANCH=${{ env.BRANCH_NAME }}'
- name: Update branch deployment status
# `always()` ensures that the deployment status
# is updated regardless of previous steps failing.
if: always()
uses: bobheadxi/deployments@648679e8e4915b27893bd7dbc35cb504dc915bc8
with:
step: finish
token: ${{ secrets.GITHUB_TOKEN }}
status: ${{ job.status }}
env: ${{ env.PREVIEW_BRANCH_NAME }}
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
env_url: https://${{ env.PREVIEW_BRANCH_NAME }}--camunda-form-playground.netlify.app
ref: ${{ env.BRANCH_NAME }}