Run Workflow on AWS Batch #67
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Run Workflow on AWS Batch | |
on: | |
push: | |
tags: | |
- "v*.*.*" | |
- "[0-9]+-[0-9]+-[0-9]+" | |
workflow_dispatch: | |
inputs: | |
revision: | |
description: Branch or tag of workflow to run | |
required: true | |
default: main | |
data_release: | |
description: Data release date | |
required: true | |
default: default | |
run_mode: | |
description: Workflow run mode | |
type: choice | |
options: | |
- test | |
- simulate-only | |
- simulated | |
- scpca | |
- full | |
output_mode: | |
description: Workflow output mode | |
type: choice | |
default: staging | |
options: | |
- staging | |
- prod | |
resume: | |
description: Use -resume flag for Nextflow launch | |
type: boolean | |
default: true | |
permissions: | |
id-token: write # This is required for requesting the JWT | |
contents: read # This is required for actions/checkout | |
jobs: | |
build: | |
name: Run Code Deploy Job | |
runs-on: ubuntu-latest | |
environment: "prod" | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Configure AWS Credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
role-to-assume: arn:aws:iam::992382809252:role/GithubOpenId-nextflow | |
role-session-name: githubActionSession | |
aws-region: us-east-1 | |
- name: Create tmux launch script | |
env: | |
# use the github tag if a push event, or the workflow input if a manual trigger | |
revision: ${{ github.event_name == 'push' && github.ref_name || inputs.revision }} | |
# default data release for release events specified, otherwise use the specified data release | |
data_release: ${{ github.event_name == 'push' && 'default' || inputs.data_release }} | |
# default run mode is full for release events, otherwise use the specified mode | |
run_mode: ${{ github.event_name == 'push' && 'full' || inputs.run_mode }} | |
# default output mode is prod for release events, otherwise use the specified mode | |
output_mode: ${{ github.event_name == 'push' && 'prod' || inputs.output_mode }} | |
resume: ${{ github.event_name == 'push' && 'true' || inputs.resume }} | |
run: | | |
echo '#!/bin/bash' > scripts/tmux_launch.sh | |
echo "export GITHUB_TAG=$revision" >> scripts/tmux_launch.sh | |
echo "export DATA_RELEASE=$data_release" >> scripts/tmux_launch.sh | |
echo "export RUN_MODE=$run_mode" >> scripts/tmux_launch.sh | |
echo "export OUTPUT_MODE=$output_mode" >> scripts/tmux_launch.sh | |
echo "export RESUME=$resume" >> scripts/tmux_launch.sh | |
echo 'tmux new-session -d -s nextflow /opt/nextflow/scripts/run_nextflow.sh' >> scripts/tmux_launch.sh | |
chmod +x scripts/tmux_launch.sh | |
- name: Create zip archive | |
run: | | |
zip -r source.zip . -i appspec.yml LICENSE scripts/** | |
working-directory: ${{ github.workspace }} | |
- name: Copy zip to S3 | |
run: aws s3 cp source.zip s3://pipeline-artifact-992382809252-us-east-2/ | |
env: | |
AWS_DEFAULT_REGION: us-east-2 | |
- name: Trigger AWS CodeDeploy deployment | |
run: | | |
aws deploy create-deployment \ | |
--application-name Batch \ | |
--deployment-group-name Batch-deployment-group \ | |
--s3-location bucket=pipeline-artifact-992382809252-us-east-2,key=source.zip,bundleType=zip \ | |
--region us-east-2 | |
env: | |
AWS_DEFAULT_REGION: us-east-2 |