Skip to content

Deploy road-backoffice-commandhost to stg: 4.15.3 #74

Deploy road-backoffice-commandhost to stg: 4.15.3

Deploy road-backoffice-commandhost to stg: 4.15.3 #74

Workflow file for this run

name: 4. Single Deploy
run-name: 'Deploy ${{ inputs.service || inputs.task || inputs.lambda }} to ${{ inputs.environment }}: ${{ inputs.version }}'
on:
workflow_dispatch:
inputs:
environment:
type: choice
description: Select the environment
options:
- tst
- stg
- prd
required: true
version:
description: Version
required: true
service:
type: choice
description: Select the service to deploy
options:
- ''
- road-backoffice-api
- road-backoffice-commandhost
- road-backoffice-eventhost
- road-backoffice-extracthost
- road-backoffice-ui
- road-editor-projectionhost
- road-producer-snapshot-projectionhost
- road-product-projectionhost
- road-projector
- road-synchost
- road-wfs-projectionhost
- road-wms-projectionhost
required: false
task:
type: choice
description: Select the task to deploy
options:
- ''
- road-adminhost
- road-jobs-processor
required: false
lambda:
type: choice
description: Select the lambda to deploy
options:
- ''
- lambdas
required: false
jobs:
deploy_start_slack:
if: github.repository_owner == 'Informatievlaanderen' && (github.event.inputs.service != '' || github.event.inputs.task != '' || github.event.inputs.lambda != '')
name: Deploy started
runs-on: ubuntu-latest
steps:
- name: Parse repository name
run: echo REPOSITORY_NAME=$(echo ""$GITHUB_REPOSITORY"" | awk -F / '{print $2}' | sed -e ""s/:refs//"") >> $GITHUB_ENV
shell: bash
- name: Uppercase environment
run: |
environment=${{ github.event.inputs.environment }}
echo "ENVIRONMENT_UPPER=${environment,,}" >>${GITHUB_ENV}
- name: Notify deployment started
uses: slackapi/[email protected]
with:
channel-id: '#team-wegenregister-dev'
slack-message: Deployment of ${{ github.event.inputs.service }} ${{ github.event.inputs.version }} to ${{ github.event.inputs.environment }} has started. View run at ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
env:
SLACK_BOT_TOKEN: ${{ secrets.VBR_SLACK_BOT_TOKEN }}
SLACK_CHANNEL: ${{ secrets.VBR_NOTIFIER_CHANNEL_NAME }}
REPOSITORY_NAME: ${{ env.REPOSITORY_NAME }}
deploy_services:
if: github.repository_owner == 'Informatievlaanderen' && github.event.inputs.service != ''
needs: [deploy_start_slack]
name: Deploy services
runs-on: ubuntu-latest
strategy:
matrix:
services: [
'${{github.event.inputs.service}}'
]
steps:
- name: CD services
env:
BUILD_URL: ${{ vars.VBR_AWS_BUILD_API_DEVOPS }}/${{matrix.services}}
STATUS_URL: ${{ vars.VBR_AWS_BUILD_STATUS_API_DEVOPS }}/${{matrix.services}}
uses: informatievlaanderen/awscurl-polling-action/polling-action@main
with:
environment: ${{ github.event.inputs.environment }}
version: ${{ github.event.inputs.version }}
status-url: $STATUS_URL
deploy-url: $BUILD_URL
access-key: ${{ secrets.VBR_AWS_ACCESS_KEY_ID_DEVOPS }}
secret-key: ${{ secrets.VBR_AWS_SECRET_ACCESS_KEY_DEVOPS }}
interval: 2
deploy-target: 'agb_ecs_service'
domain: 'basisregisters'
project: 'basisregisters'
- name: Output CD services
shell: bash
run: |
echo build-uuid: ${{ steps.awscurl-polling-action.outputs.build-uuid }}
echo Status: ${{ steps.awscurl-polling-action.outputs.status }}
echo ${{ steps.awscurl-polling-action.outputs.final-message }}
deploy_tasks:
if: github.repository_owner == 'Informatievlaanderen' && github.event.inputs.task != ''
needs: [deploy_start_slack]
name: Deploy tasks
runs-on: ubuntu-latest
strategy:
matrix:
services: [
'${{github.event.inputs.task}}'
]
steps:
- name: CD services
env:
BUILD_URL: ${{ vars.VBR_AWS_BUILD_API_DEVOPS }}/${{matrix.services}}
STATUS_URL: ${{ vars.VBR_AWS_BUILD_STATUS_API_DEVOPS }}/${{matrix.services}}
uses: informatievlaanderen/awscurl-polling-action/polling-action@main
with:
environment: ${{ github.event.inputs.environment }}
version: ${{ github.event.inputs.version }}
status-url: $STATUS_URL
deploy-url: $BUILD_URL
access-key: ${{ secrets.VBR_AWS_ACCESS_KEY_ID_DEVOPS }}
secret-key: ${{ secrets.VBR_AWS_SECRET_ACCESS_KEY_DEVOPS }}
interval: 2
deploy-target: 'ecs_scheduled_task'
domain: 'basisregisters'
project: 'basisregisters'
- name: Output CD tasks
shell: bash
run: |
echo build-uuid: ${{ steps.awscurl-polling-action.outputs.build-uuid }}
echo Status: ${{ steps.awscurl-polling-action.outputs.status }}
echo ${{ steps.awscurl-polling-action.outputs.final-message }}
deploy_lambda:
if: github.repository_owner == 'Informatievlaanderen' && github.event.inputs.lambda != ''
needs: [deploy_start_slack]
name: Deploy lambda(s)
runs-on: ubuntu-latest
steps:
- name: CD Lambda(s) Configure credentials
uses: aws-actions/[email protected]
with:
aws-access-key-id: ${{ github.event.inputs.environment == 'tst' && secrets.VBR_AWS_ACCESS_KEY_ID_DEVOPS || github.event.inputs.environment == 'stg' && secrets.VBR_AWS_ACCESS_KEY_ID || github.event.inputs.environment == 'prd' && secrets.VBR_AWS_ACCESS_KEY_ID_NEWPRD || ''}}
aws-secret-access-key: ${{ github.event.inputs.environment == 'tst' && secrets.VBR_AWS_SECRET_ACCESS_KEY_DEVOPS || github.event.inputs.environment == 'stg' && secrets.VBR_AWS_SECRET_ACCESS_KEY || github.event.inputs.environment == 'prd' && secrets.VBR_AWS_SECRET_ACCESS_KEY_NEWPRD || ''}}
aws-region: ${{ secrets.VBR_AWS_REGION_PRD }}
- name: Prepare Lambda(s)
if: github.event.inputs.environment == 'prd'
shell: bash
run: |
aws s3 cp $S3_BASEURL-$FUNCTION_BACKOFFICE/$VERSION/lambda.zip $S3_BASEURL-$FUNCTION_BACKOFFICE/lambda.zip --copy-props none
aws s3 cp $S3_BASEURL-$FUNCTION_SNAPSHOT/$VERSION/lambda.zip $S3_BASEURL-$FUNCTION_SNAPSHOT/lambda.zip --copy-props none
env:
VERSION: ${{ github.event.inputs.version }}
S3_BASEURL: ${{ github.event.inputs.environment == 'tst' && 's3://s3-vbr-tst-basisregisters-lam' || github.event.inputs.environment == 'stg' && 's3://s3-vbr-stg-basisregisters-lam' || github.event.inputs.environment == 'prd' && 's3://077849980894-vbr-prd-lam' || '' }}
FUNCTION_BACKOFFICE: ${{ github.event.inputs.environment == 'tst' && 'rr-sqsbackofficefunction' || github.event.inputs.environment == 'stg' && 'wr-sqsbackofficehandlerfunction' || github.event.inputs.environment == 'prd' && 'rr-sqsbackoffice' || '' }}
FUNCTION_SNAPSHOT: ${{ github.event.inputs.environment == 'tst' && 'rr-sqssnapshotfunction' || github.event.inputs.environment == 'stg' && 'wr-sqssnapshothandlerfunction' || github.event.inputs.environment == 'prd' && 'rr-sqssnapshot' || '' }}
- name: Promote Lambda(s)
if: github.event.inputs.environment == 'prd'
shell: bash
run: |
docker pull ghcr.io/okigan/awscurl:latest
docker run --rm okigan/awscurl --access_key $ACCESS_KEY_ID --secret_key $SECRET_ACCESS_KEY_ID --region $REGION -X POST -d '{ "functionName": "'$FUNCTION_BACKOFFICE'", "project": "basisregisters", "domain": "basisregisters" }' $PROMOTEURL/$ENVIRONMENT
docker run --rm okigan/awscurl --access_key $ACCESS_KEY_ID --secret_key $SECRET_ACCESS_KEY_ID --region $REGION -X POST -d '{ "functionName": "'$FUNCTION_SNAPSHOT'", "project": "basisregisters", "domain": "basisregisters" }' $PROMOTEURL/$ENVIRONMENT
env:
ACCESS_KEY_ID: ${{ github.event.inputs.environment == 'tst' && secrets.VBR_AWS_ACCESS_KEY_ID_DEVOPS || secrets.VBR_AWS_ACCESS_KEY_ID_TST }}
SECRET_ACCESS_KEY_ID: ${{ github.event.inputs.environment == 'tst' && secrets.VBR_AWS_SECRET_ACCESS_KEY_DEVOPS || secrets.VBR_AWS_SECRET_ACCESS_KEY_TST }}
ENVIRONMENT: ${{ github.event.inputs.environment == 'tst' && 'tst' || github.event.inputs.environment == 'prd' && 'acc' || github.event.inputs.environment }}
REGION: ${{ secrets.VBR_AWS_REGION_PRD }}
PROMOTEURL: ${{ github.event.inputs.environment == 'tst' && vars.VBR_AWS_PROMOTE_LAMBDA_DEVOPS_BASEURL || secrets.VBR_AWS_PROMOTE_LAMBDA_BASEURL }}
FUNCTION_BACKOFFICE: ${{ github.event.inputs.environment == 'tst' && 'rr-sqsbackofficefunction' || github.event.inputs.environment == 'stg' && 'wr-sqsbackofficehandlerfunction' || github.event.inputs.environment == 'prd' && 'rr-sqsbackofficefunction' || '' }}
FUNCTION_SNAPSHOT: ${{ github.event.inputs.environment == 'tst' && 'rr-sqssnapshotfunction' || github.event.inputs.environment == 'stg' && 'wr-sqssnapshothandlerfunction' || github.event.inputs.environment == 'prd' && 'rr-sqssnapshotfunction' || '' }}
- name: Promote BackOffice Lambda
if: github.event.inputs.environment != 'prd'
uses: Informatievlaanderen/build-pipeline/.github/actions/deploy-lambda@main
with:
function-name: rr-sqsbackofficefunction
deploy-url: ${{ vars.VBR_AWS_DEPLOY_LAMBDA_DEVOPS_BASEURL }}
access-key-id: ${{ secrets.VBR_AWS_ACCESS_KEY_ID_DEVOPS }}
secret-access-key-id: ${{ secrets.VBR_AWS_SECRET_ACCESS_KEY_DEVOPS }}
region: ${{ secrets.VBR_AWS_REGION_PRD }}
version: ${{ github.event.inputs.version }}
environment: ${{ github.event.inputs.environment }}
- name: Promote Snapshot Lambda
if: github.event.inputs.environment != 'prd'
uses: Informatievlaanderen/build-pipeline/.github/actions/deploy-lambda@main
with:
function-name: rr-sqssnapshotfunction
deploy-url: ${{ vars.VBR_AWS_DEPLOY_LAMBDA_DEVOPS_BASEURL }}
access-key-id: ${{ secrets.VBR_AWS_ACCESS_KEY_ID_DEVOPS }}
secret-access-key-id: ${{ secrets.VBR_AWS_SECRET_ACCESS_KEY_DEVOPS }}
region: ${{ secrets.VBR_AWS_REGION_PRD }}
version: ${{ github.event.inputs.version }}
environment: ${{ github.event.inputs.environment }}
deploy_finish_slack:
if: github.repository_owner == 'Informatievlaanderen'
needs: [deploy_services, deploy_tasks, deploy_lambda]
name: Deploy finished
runs-on: ubuntu-latest
steps:
- name: Parse repository name
run: echo REPOSITORY_NAME=$(echo ""$GITHUB_REPOSITORY"" | awk -F / '{print $2}' | sed -e ""s/:refs//"") >> $GITHUB_ENV
shell: bash
- name: Notify deployment finished
uses: slackapi/[email protected]
with:
channel-id: '#team-wegenregister-dev'
slack-message: ":white_check_mark: Deployment of ${{ github.event.inputs.service || github.event.inputs.task || github.event.inputs.lambda }} ${{ github.event.inputs.version }} to ${{ github.event.inputs.environment }} has finished."
env:
SLACK_BOT_TOKEN: ${{ secrets.VBR_SLACK_BOT_TOKEN }}
SLACK_CHANNEL: ${{ secrets.VBR_NOTIFIER_CHANNEL_NAME }}
REPOSITORY_NAME: ${{ env.REPOSITORY_NAME }}
deploy_nothing_slack:
if: github.repository_owner == 'Informatievlaanderen' && (github.event.inputs.service == '' || github.event.inputs.task == '' || github.event.inputs.lambda == '')
needs: [deploy_services, deploy_tasks, deploy_lambda]
name: Deploy cancelled
runs-on: ubuntu-latest
steps:
- name: Parse repository name
run: echo REPOSITORY_NAME=$(echo ""$GITHUB_REPOSITORY"" | awk -F / '{print $2}' | sed -e ""s/:refs//"") >> $GITHUB_ENV
shell: bash
- name: Notify deployment cancelled
uses: slackapi/[email protected]
with:
channel-id: '#team-wegenregister-dev'
slack-message: ":x: No service/task/lambda was selected to be deployed."
env:
SLACK_BOT_TOKEN: ${{ secrets.VBR_SLACK_BOT_TOKEN }}
SLACK_CHANNEL: ${{ secrets.VBR_NOTIFIER_CHANNEL_NAME }}
REPOSITORY_NAME: ${{ env.REPOSITORY_NAME }}
deployment_notify_failure:
if: ${{ github.repository_owner == 'Informatievlaanderen' && failure() }}
name: Notify deployment failed
runs-on: ubuntu-latest
needs: [ deploy_services, deploy_tasks, deploy_lambda ]
steps:
- name: Notify deployment failed
id: slack
uses: slackapi/[email protected]
with:
channel-id: '#team-wegenregister-dev'
slack-message: ":x: Deployment of road-registry ${{ github.event.inputs.version }} to ${{ github.event.inputs.environment }} has failed. View run at ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
env:
SLACK_BOT_TOKEN: ${{ secrets.VBR_SLACK_BOT_TOKEN }}
SLACK_CHANNEL: ${{ secrets.VBR_NOTIFIER_CHANNEL_NAME }}