Set the dr deployment to active #354
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: Set the dr deployment to active | |
on: | |
workflow_dispatch: | |
inputs: | |
project: | |
description: "The target project" | |
type: choice | |
required: true | |
options: ["SANDBOX", "PRODUCTION", "OLD-SANDBOX"] | |
default: "SANDBOX" | |
environment: | |
description: "env to deploy" | |
type: choice | |
options: ["dev", "test", "prod"] | |
default: "dev" | |
jobs: | |
alert-sso-alerts: | |
runs-on: ubuntu-22.04 | |
timeout-minutes: 60 | |
steps: | |
- name: Choose RC Notification Color | |
run: | | |
if [[ "${{ job.status }}" == "success" ]]; then | |
echo "RC_NOTIFICATION_COLOR=#2DEDA5" >> $GITHUB_ENV | |
echo "RC_NOTIFICATION_JOB_STATUS=succeeded" >> $GITHUB_ENV | |
else | |
echo "RC_NOTIFICATION_COLOR=#F5455C" >> $GITHUB_ENV | |
echo "RC_NOTIFICATION_JOB_STATUS=failed" >> $GITHUB_ENV | |
fi | |
echo ${{ env.RC_NOTIFICATION_COLOR }} | |
- name: Rocket.Chat Notification | |
uses: fjogeleit/http-request-action@v1 | |
with: | |
url: ${{ secrets.SSO_ALERTS }} | |
method: "POST" | |
customHeaders: '{"Content-Type": "application/json"}' | |
data: '{"text": "@jsharman @nithinshekar.kuruba @jlanglois @Marco The switch to Gold DR action was triggered for the ${{ github.event.inputs.project }}-${{ github.event.inputs.environment }} project, confirm if ${{ env.RC_NOTIFICATION_JOB_STATUS }}?", "attachments": [{"color": "${{ env.RC_NOTIFICATION_COLOR }}","title": "Details", "title_link": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}", "text": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}", "fields": [{"title": "Ref", "value": "${{ github.ref }}", "short": false}, {"title": "Workflow", "value": "${{ github.workflow }}", "short": false}]}]}' | |
transition-scripts: | |
runs-on: ubuntu-22.04 | |
timeout-minutes: 60 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set the deployment namespace | |
run: | | |
chmod +x ./namespace-setter.sh | |
./namespace-setter.sh ${{ github.event.inputs.project }} ${{ github.event.inputs.environment }} | |
working-directory: .github/helpers | |
- name: Login Openshift Gold & Golddr | |
uses: ./.github/actions/oc-login | |
with: | |
namespace: $NAMESPACE | |
oc-server-gold: ${{ secrets.OPENSHIFT_SERVER_GOLD }} | |
oc-token-gold: ${{ secrets.OPENSHIFT_TOKEN_GOLD }} | |
oc-server-golddr: ${{ secrets.OPENSHIFT_SERVER_GOLDDR }} | |
oc-token-golddr: ${{ secrets.OPENSHIFT_TOKEN_GOLDDR }} | |
- name: Run transition script | |
run: | | |
echo "Running on the $NAMESPACE namespace" | |
chmod +x ./switch-to-golddr.sh | |
./switch-to-golddr.sh $NAMESPACE | |
working-directory: transition-scripts | |
- name: Alert on failure | |
if: failure() | |
uses: fjogeleit/http-request-action@v1 | |
with: | |
url: ${{ secrets.SSO_ALERTS }} | |
method: "POST" | |
customHeaders: '{"Content-Type": "application/json"}' | |
data: '{"text": "@jsharman @nithinshekar.kuruba @jlanglois @Marco The switch to Gold DR for the ${{ github.event.inputs.project }}-${{ github.event.inputs.environment }} project failed", "attachments": [{"color": "#F5455C","title": "Details", "title_link": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}", "text": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}", "fields": [{"title": "Ref", "value": "${{ github.ref }}", "short": false}, {"title": "Workflow", "value": "${{ github.workflow }}", "short": false}]}]}' |