DPC - Build and Deploy #9
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: 'Build and Deploy' | |
on: | |
schedule: | |
- cron: '0 6 * * 1-5' | |
push: | |
branches: | |
- main | |
paths: | |
- dpc-** | |
- engines/** | |
workflow_dispatch: | |
inputs: | |
env: | |
description: AWS environment to deploy to | |
required: true | |
type: 'string' | |
default: 'dev' | |
confirm_env: | |
description: Double check for environment | |
required: true | |
type: 'string' | |
default: '' | |
ops-ref: | |
description: Branch of dpc-ops to use | |
required: false | |
type: 'string' | |
default: 'main' | |
concurrency: | |
group: ${{ github.workflow }}-top-${{ inputs.env || 'dev' }} | |
cancel-in-progress: false | |
jobs: | |
set-parameters: | |
name: "Set Parameters" | |
runs-on: self-hosted | |
outputs: | |
version_tag: ${{ steps.get-version-tag.outputs.version_tag }} | |
steps: | |
- name: "Validate Environment" | |
if: ${{ github.event_name == 'workflow_dispatch' && inputs.env != inputs.confirm_env }} | |
run: | | |
echo "Target deployment environment \"${{ inputs.env }}\" must be specified and match confirmed deployment environment \"${{ inputs.confirm_env }}\"." | |
exit 1 | |
- name: "Checkout code" | |
uses: actions/checkout@v4 | |
- name: "Fetch git info" | |
run: | | |
git fetch --quiet | |
- name: "Get Version Tag" | |
id: get-version-tag | |
run: | | |
set +e | |
VERSION_TAG=`git describe --tags --exact-match` | |
if [ $? -ne 0 ]; then | |
BRANCH_HASH=`git show -s --format='%h'` | |
VERSION_TAG="commit_${BRANCH_HASH}" | |
fi | |
echo $VERSION_TAG | |
echo "version_tag=$VERSION_TAG" >> "$GITHUB_OUTPUT" | |
set -e | |
build: | |
name: "Build Images" | |
needs: | |
- set-parameters | |
uses: ./.github/workflows/docker-build.yml | |
secrets: inherit | |
deploy: | |
needs: | |
- set-parameters | |
- build | |
uses: ./.github/workflows/ecs-deploy.yml | |
with: | |
env: ${{ inputs.env || 'dev' }} | |
confirm_env: ${{ inputs.env || 'dev' }} | |
ecr_image_tag: ${{ needs.build.outputs.ecr_image_tag }} | |
app-version: ${{ needs.set-parameters.outputs.version_tag }} | |
ops-ref: ${{ inputs.ops-ref || 'main' }} | |
secrets: inherit | |
smoke-test: | |
needs: deploy | |
uses: ./.github/workflows/smoke-test.yml | |
with: | |
env: ${{ inputs.env || 'dev' }} | |
secrets: inherit |