Reload HRM configuration via forced update #42
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
# Copyright (C) 2021-2023 Technology Matters | |
# This program is free software: you can redistribute it and/or modify | |
# it under the terms of the GNU Affero General Public License as published | |
# by the Free Software Foundation, either version 3 of the License, or | |
# (at your option) any later version. | |
# | |
# This program is distributed in the hope that it will be useful, | |
# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
# GNU Affero General Public License for more details. | |
# | |
# You should have received a copy of the GNU Affero General Public License | |
# along with this program. If not, see https://www.gnu.org/licenses/. | |
name: 'Reload HRM configuration via forced update' | |
on: | |
workflow_dispatch: | |
inputs: | |
environment: | |
description: HRM environment to update. E.G = development, staging, production (must match with the AWS environment value). Default value = development | |
default: development | |
required: true | |
type: choice | |
options: | |
- development | |
- staging | |
- production | |
region: | |
description: AWS region to update. E.G = us-east-1, eu-west-1 (must match with the AWS environment value). Default value = us-east-1 | |
default: us-east-1 | |
required: true | |
type: choice | |
options: | |
- us-east-1 | |
- eu-west-1 | |
- ca-central-1 | |
workflow_call: | |
secrets: | |
AWS_ACCESS_KEY_ID: | |
required: true | |
AWS_SECRET_ACCESS_KEY: | |
required: true | |
# Should probably use the passed in region for everything but the GITHUB_ACTIONS_SLACK_BOT_TOKEN SSM parameter only exists in us-east-1 | |
AWS_DEFAULT_REGION: | |
required: true | |
inputs: | |
environment: | |
description: HRM environment to update. E.G = development, staging, production (must match with the AWS environment value). Default value = development | |
type: string | |
default: development | |
required: true | |
region: | |
description: AWS region to update. E.G = us-east-1, eu-west-1 (must match with the AWS environment value). Default value = us-east-1 | |
type: string | |
default: us-east-1 | |
required: true | |
send-slack-message: | |
description: 'Specifies if should send a Slack message at the end of successful run. Defaults to true' | |
required: false | |
default: 'true' | |
type: string | |
env: | |
AWS_DEFAULT_REGION: ${{ inputs.region }} | |
jobs: | |
deploy: | |
name: Update | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: ${{ inputs.region }} | |
- name: Force update of ECS poller service | |
run: aws ecs update-service --cluster ${{ inputs.environment }}-ecs-cluster --service ${{ inputs.environment }}-job-processor --force-new-deployment | |
- name: Force update of ECS service | |
run: aws ecs update-service --cluster ${{ inputs.environment }}-ecs-cluster --service ${{ inputs.environment }}-ecs-service --force-new-deployment | |
# TODO: force reload of lambdas as well | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: ${{ secrets.AWS_DEFAULT_REGION }} | |
# Set any env vars needed from Parameter Store here | |
- name: Set GITHUB_ACTIONS_SLACK_BOT_TOKEN | |
uses: 'marvinpinto/action-inject-ssm-secrets@latest' | |
with: | |
ssm_parameter: 'GITHUB_ACTIONS_SLACK_BOT_TOKEN' | |
env_variable_name: 'GITHUB_ACTIONS_SLACK_BOT_TOKEN' | |
- name: Set ASELO_DEPLOYS_CHANNEL_ID | |
uses: 'marvinpinto/action-inject-ssm-secrets@latest' | |
with: | |
ssm_parameter: 'ASELO_DEPLOYS_CHANNEL_ID' | |
env_variable_name: 'ASELO_DEPLOYS_CHANNEL_ID' | |
# Send Slack notifying success | |
- name: Slack Aselo channel | |
id: slack | |
uses: slackapi/[email protected] | |
with: | |
channel-id: ${{ env.ASELO_DEPLOYS_CHANNEL_ID }} | |
slack-message: '`[HRM]` Service reload requested by `${{ github.triggering_actor }}` to region `${{ inputs.region }}`, environment `${{ inputs.environment }}` :rocket:.' | |
env: | |
SLACK_BOT_TOKEN: ${{ env.GITHUB_ACTIONS_SLACK_BOT_TOKEN }} | |
if: ${{ inputs.send-slack-message != 'false' }} |