Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/workflows/deploy-on-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Triggers Deployment on Pull Request Merge
on:
pull_request:
types: [closed]
branches: [develop, staging, production]
jobs:
on-merge:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
outputs:
target_branch: ${{ steps.get_branch.outputs.branch_name }}
steps:
- name: Get the target branch
id: get_branch
run: echo "branch_name=${{ github.base_ref }}" >> $GITHUB_OUTPUT

trigger-deploy-workflow:
needs: on-merge
uses: ./.github/workflows/deploy-to-blob.yml
with:
environment: ${{ needs.on-merge.outputs.target_branch }}
version: 'latest'
secrets: inherit
82 changes: 82 additions & 0 deletions .github/workflows/deploy-to-blob.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Release to Azure Blob Storage
on:
workflow_dispatch:
inputs:
environment:
description: 'Environment to deploy to'
required: true
default: 'develop'
type: choice
options:
- develop
- staging
- production
version:
description: 'Version to deploy'
required: true
default: 'latest'
workflow_call:
inputs:
environment:
description: 'Environment to deploy to'
required: true
default: 'develop'
type: string
version:
description: 'Version to deploy'
required: true
default: 'latest'
type: string
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ inputs.environment }}

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'

# Infer the environment from the workflow input and set the appropriate environment variable
- name: Set the target container
run: |
if [ "${{ inputs.environment }}" == "develop" ]; then
echo "TARGET_CONTAINER=dev" >> $GITHUB_ENV
elif [ "${{ inputs.environment }}" == "staging" ]; then
echo "TARGET_CONTAINER=stage" >> $GITHUB_ENV
elif [ "${{ inputs.environment }}" == "production" ]; then
echo "TARGET_CONTAINER=prod" >> $GITHUB_ENV
else
echo "Invalid environment specified"
exit 1
fi

- name: Install dependencies
run: npm clean-install
env:
FORCE_COLOR: 2

- name: Build
run: npm run all
env:
FORCE_COLOR: 2

- name: Gather build artifacts
run: |
mkdir -p build
cp -r dist/* build/
echo "Files in build directory:"
ls -R build

- name: Upload to Azure Blob Storage
uses: LanceMcCarthy/Action-AzureBlobUpload@v3
with:
source_folder: 'build'
connection_string: ${{ secrets.AZURE_STORAGE_CONNECTION_STRING }}
container_name: 'pathways-editor'
destination_folder: '${{ env.TARGET_CONTAINER }}'
delete_if_exists: true
Loading