1
- name : V2 Deploy Master to Production Environment
1
+ name : V2 Deploy Demos to SWC Environment
2
2
3
3
on :
4
4
workflow_run :
5
5
workflows :
6
- - " V2 Build Master for Production Environment"
6
+ - " V2 Build Demos for SWC Environment"
7
7
types :
8
8
- completed
9
9
@@ -13,7 +13,7 @@ permissions:
13
13
contents : read
14
14
15
15
concurrency :
16
- group : deploy- v2-demos-master -${{ github.event.workflow_run.head_branch }}
16
+ group : v2-deploy- demos-swc -${{ github.event.workflow_run.head_branch }}
17
17
cancel-in-progress : true
18
18
19
19
jobs :
@@ -26,13 +26,13 @@ jobs:
26
26
uses : XanaduAI/cloud-actions/download-github-workflow-artifact@main
27
27
with :
28
28
workflow_run_id : ${{ github.event.workflow_run.id }}
29
- artifact_name_regex : ' ^master_build_context $'
29
+ artifact_name_regex : ' ^deployment_build_context $'
30
30
github_token : ${{ github.token }}
31
31
32
32
- name : Check if Build Context file exists
33
33
id : build_context
34
34
env :
35
- context_artifact_file_name : master_build_context .zip
35
+ context_artifact_file_name : deployment_build_context .zip
36
36
run : |
37
37
if test -f "$context_artifact_file_name"; then
38
38
echo "result=$context_artifact_file_name" >> $GITHUB_OUTPUT
@@ -49,37 +49,56 @@ jobs:
49
49
with :
50
50
script : |
51
51
const fs = require('fs');
52
- const buildData = fs.readFileSync('master_build_context .json', 'utf8');
52
+ const buildData = fs.readFileSync('deployment_build_context .json', 'utf8');
53
53
return JSON.parse(buildData);
54
54
55
55
- name : Parse Push Event Information
56
56
id : pr_info
57
57
if : github.event.workflow_run.event == 'push' && steps.build_context.outputs.result != ''
58
58
run : |
59
59
echo '${{ steps.read_build_info.outputs.result }}' | jq -r '.ref' > merge_ref.txt
60
+ echo '${{ steps.read_build_info.outputs.result }}' | jq -r '.ref_name' > merge_ref_name.txt
60
61
echo '${{ steps.read_build_info.outputs.result }}' | jq -c '.updated_demos' > updated_demos.json
61
62
echo '${{ steps.read_build_info.outputs.result }}' | jq -c '.deleted_demos' > deleted_demos.json
62
63
63
64
echo "merge_ref=$(cat merge_ref.txt)" >> $GITHUB_OUTPUT
65
+ echo "merge_ref_name=$(cat merge_ref_name.txt)" >> $GITHUB_OUTPUT
64
66
echo "updated_demos=$(cat updated_demos.json)" >> $GITHUB_OUTPUT
65
67
echo "deleted_demos=$(cat deleted_demos.json)" >> $GITHUB_OUTPUT
68
+
69
+ - name : Determine SWC environment via merge_ref_name
70
+ if : steps.pr_info.outputs.merge_ref_name != ''
71
+ id : determine_env
72
+ # # Todo: Remove test-v2-master and test-v2-dev once the new branches are fully adopted
73
+ # # Todo: Update master to deploy into swc-prod environment instead of swc-staging
74
+ run : |
75
+ if [[ "${{ steps.pr_info.outputs.merge_ref_name }}" == "master" || "${{ steps.pr_info.outputs.merge_ref_name }}" == "test-v2-master" ]]; then
76
+ echo "swc-env=swc-staging" >> $GITHUB_OUTPUT
77
+ elif [[ "${{ steps.pr_info.outputs.merge_ref_name }}" == "dev" || "${{ steps.pr_info.outputs.merge_ref_name }}" == "test-v2-dev" ]]; then
78
+ echo "swc-env=swc-dev" >> $GITHUB_OUTPUT
79
+ else
80
+ echo "Unknown branch: ${{ steps.pr_info.outputs.merge_ref_name }}"
81
+ exit 1
82
+ fi
66
83
outputs :
67
84
merge_ref : ${{ steps.pr_info.outputs.merge_ref }}
85
+ merge_ref_name : ${{ steps.pr_info.outputs.merge_ref_name }}
68
86
updated_demos : ${{ steps.pr_info.outputs.updated_demos }}
69
87
deleted_demos : ${{ steps.pr_info.outputs.deleted_demos }}
88
+ swc-env : ${{ steps.determine_env.outputs.swc-env }}
70
89
71
- # Step 2: Deploy the demos to SWC production environment
90
+ # Step 2: Deploy the demos to SWC
72
91
deploy-production-demos :
73
92
if : |
74
93
github.event.workflow_run.event == 'push' &&
75
94
needs.prepare-build-context.result == 'success' &&
76
- needs.prepare-build-context.outputs.merge_ref != ''
95
+ needs.prepare-build-context.outputs.merge_ref != '' &&
96
+ needs.prepare-build-context.outputs.updated_demos != '[]'
77
97
uses : ./.github/workflows/v2-deploy-demos.yml
78
98
needs : prepare-build-context
79
99
with :
80
- # Change to 'swc-prod' when ready for release
81
- environment : ' swc-dev'
82
- artifact-name : demo-master-build-${{ needs.prepare-build-context.outputs.merge_ref }}
100
+ environment : ${{ needs.prepare-build-context.outputs.swc-env }}
101
+ artifact-name : demo-deployment-build-${{ needs.prepare-build-context.outputs.merge_ref }}
83
102
workflow-run-id : ${{ github.event.workflow_run.id }}
84
103
pr_number : 0
85
104
secrets : inherit
0 commit comments