1- name : V2 Deploy Master to Production Environment
1+ name : V2 Deploy Demos to SWC Environment
22
33on :
44 workflow_run :
55 workflows :
6- - " V2 Build Master for Production Environment"
6+ - " V2 Build Demos for SWC Environment"
77 types :
88 - completed
99
@@ -13,7 +13,7 @@ permissions:
1313 contents : read
1414
1515concurrency :
16- group : deploy- v2-demos-master -${{ github.event.workflow_run.head_branch }}
16+ group : v2-deploy- demos-swc -${{ github.event.workflow_run.head_branch }}
1717 cancel-in-progress : true
1818
1919jobs :
@@ -26,13 +26,13 @@ jobs:
2626 uses : XanaduAI/cloud-actions/download-github-workflow-artifact@main
2727 with :
2828 workflow_run_id : ${{ github.event.workflow_run.id }}
29- artifact_name_regex : ' ^master_build_context $'
29+ artifact_name_regex : ' ^deployment_build_context $'
3030 github_token : ${{ github.token }}
3131
3232 - name : Check if Build Context file exists
3333 id : build_context
3434 env :
35- context_artifact_file_name : master_build_context .zip
35+ context_artifact_file_name : deployment_build_context .zip
3636 run : |
3737 if test -f "$context_artifact_file_name"; then
3838 echo "result=$context_artifact_file_name" >> $GITHUB_OUTPUT
@@ -49,37 +49,56 @@ jobs:
4949 with :
5050 script : |
5151 const fs = require('fs');
52- const buildData = fs.readFileSync('master_build_context .json', 'utf8');
52+ const buildData = fs.readFileSync('deployment_build_context .json', 'utf8');
5353 return JSON.parse(buildData);
5454
5555 - name : Parse Push Event Information
5656 id : pr_info
5757 if : github.event.workflow_run.event == 'push' && steps.build_context.outputs.result != ''
5858 run : |
5959 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
6061 echo '${{ steps.read_build_info.outputs.result }}' | jq -c '.updated_demos' > updated_demos.json
6162 echo '${{ steps.read_build_info.outputs.result }}' | jq -c '.deleted_demos' > deleted_demos.json
6263
6364 echo "merge_ref=$(cat merge_ref.txt)" >> $GITHUB_OUTPUT
65+ echo "merge_ref_name=$(cat merge_ref_name.txt)" >> $GITHUB_OUTPUT
6466 echo "updated_demos=$(cat updated_demos.json)" >> $GITHUB_OUTPUT
6567 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
6683 outputs :
6784 merge_ref : ${{ steps.pr_info.outputs.merge_ref }}
85+ merge_ref_name : ${{ steps.pr_info.outputs.merge_ref_name }}
6886 updated_demos : ${{ steps.pr_info.outputs.updated_demos }}
6987 deleted_demos : ${{ steps.pr_info.outputs.deleted_demos }}
88+ swc-env : ${{ steps.determine_env.outputs.swc-env }}
7089
71- # Step 2: Deploy the demos to SWC production environment
90+ # Step 2: Deploy the demos to SWC
7291 deploy-production-demos :
7392 if : |
7493 github.event.workflow_run.event == 'push' &&
7594 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 != '[]'
7797 uses : ./.github/workflows/v2-deploy-demos.yml
7898 needs : prepare-build-context
7999 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 }}
83102 workflow-run-id : ${{ github.event.workflow_run.id }}
84103 pr_number : 0
85104 secrets : inherit
0 commit comments