File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : Triggers Deployment on Pull Request Merge
2+ on :
3+ pull_request :
4+ types : [closed]
5+ branches : [develop, staging, production]
6+ jobs :
7+ on-merge :
8+ if : github.event.pull_request.merged == true
9+ runs-on : ubuntu-latest
10+ outputs :
11+ target_branch : ${{ steps.get_branch.outputs.branch_name }}
12+ steps :
13+ - name : Get the target branch
14+ id : get_branch
15+ run : echo "branch_name=${{ github.base_ref }}" >> $GITHUB_OUTPUT
16+
17+ trigger-deploy-workflow :
18+ needs : on-merge
19+ uses : ./.github/workflows/deploy-to-blob.yml
20+ with :
21+ environment : ${{ needs.on-merge.outputs.target_branch }}
22+ version : ' latest'
23+ secrets : inherit
Original file line number Diff line number Diff line change 1+ name : Release to Azure Blob Storage
2+ on :
3+ workflow_dispatch :
4+ inputs :
5+ environment :
6+ description : ' Environment to deploy to'
7+ required : true
8+ default : ' develop'
9+ type : choice
10+ options :
11+ - develop
12+ - staging
13+ - production
14+ version :
15+ description : ' Version to deploy'
16+ required : true
17+ default : ' latest'
18+ workflow_call :
19+ inputs :
20+ environment :
21+ description : ' Environment to deploy to'
22+ required : true
23+ default : ' develop'
24+ type : string
25+ version :
26+ description : ' Version to deploy'
27+ required : true
28+ default : ' latest'
29+ type : string
30+ jobs :
31+ deploy :
32+ runs-on : ubuntu-latest
33+ steps :
34+ - name : Checkout code
35+ uses : actions/checkout@v4
36+ with :
37+ ref : ${{ inputs.environment }}
38+
39+ - name : Set up Node.js
40+ uses : actions/setup-node@v4
41+ with :
42+ node-version : ' 20'
43+
44+ # Infer the environment from the workflow input and set the appropriate environment variable
45+ - name : Set the target container
46+ run : |
47+ if [ "${{ inputs.environment }}" == "develop" ]; then
48+ echo "TARGET_CONTAINER=dev" >> $GITHUB_ENV
49+ elif [ "${{ inputs.environment }}" == "staging" ]; then
50+ echo "TARGET_CONTAINER=stage" >> $GITHUB_ENV
51+ elif [ "${{ inputs.environment }}" == "production" ]; then
52+ echo "TARGET_CONTAINER=prod" >> $GITHUB_ENV
53+ else
54+ echo "Invalid environment specified"
55+ exit 1
56+ fi
57+
58+ - name : Install dependencies
59+ run : npm clean-install
60+ env :
61+ FORCE_COLOR : 2
62+
63+ - name : Build
64+ run : npm run all
65+ env :
66+ FORCE_COLOR : 2
67+
68+ - name : Gather build artifacts
69+ run : |
70+ mkdir -p build
71+ cp -r dist/* build/
72+ echo "Files in build directory:"
73+ ls -R build
74+
75+ - name : Upload to Azure Blob Storage
76+ uses : LanceMcCarthy/Action-AzureBlobUpload@v3
77+ with :
78+ source_folder : ' build'
79+ connection_string : ${{ secrets.AZURE_STORAGE_CONNECTION_STRING }}
80+ container_name : ' pathways-editor'
81+ destination_folder : ' ${{ env.TARGET_CONTAINER }}'
82+ delete_if_exists : true
You can’t perform that action at this time.
0 commit comments