Skip to content

Deploy to MNbenefits ATST #79

Deploy to MNbenefits ATST

Deploy to MNbenefits ATST #79

name: Deploy to MNbenefits ATST
on:
workflow_dispatch:
inputs:
branch:
description: 'Target branch to be released'
required: true
default: staging
jobs:
draft-release:
name: Draft a new release
runs-on: ubuntu-latest
permissions: write-all
outputs:
tag_name: release-${{ steps.create-tagname.outputs.TAG_NAME }}
steps:
- name: Create tag name
id: create-tagname
run: echo "TAG_NAME=$(date +'%Y-%m-%d-%H%M')" >> $GITHUB_OUTPUT
- name: Draft Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: release-${{ steps.create-tagname.outputs.TAG_NAME }}
release_name: release-${{ steps.create-tagname.outputs.TAG_NAME }}
commitish: ${{ github.event.inputs.branch }}
body: |
Fill in details about this release
draft: true
prerelease: true
# Deploy to MNbenefits ATST steps:
# 1. find latest git release
# 2. Login to openshift non-prod
# 3. update build config, set git ref to the release tag
# 4. update build config, set image tag to the release tag
# 5. build image
# 6. update deployment config to the release tag
# 7. rollout updated image
mnitdeploy:
name: deploy to MNbenefits ATST
needs: draft-release
runs-on: ubuntu-latest
steps:
- name: Authenticate and set context for non-prod
uses: redhat-actions/oc-login@v1
with:
openshift_server_url: ${{ secrets.OPENSHIFT_SERVER_NON_PROD }}
openshift_token: ${{ secrets.OPENSHIFT_TOKEN_NON_PROD }}
namespace: ${{ secrets.OPENSHIFT_NAMESPACE_NON_PROD }}
- name: update and run build
run: |
oc patch bc mn-benefits-release -p '{"spec":{"source":{"git":{"ref":"${{ github.event.inputs.branch }}"}}}}'
oc patch bc mn-benefits-release -p '{"spec":{"output":{"to":{"name":"mn-benefits:${{ needs.draft-release.outputs.tag_name }}"}}}}'
oc start-build mn-benefits-release --follow
oc patch dc mn-benefits-atst -p '{"spec":{"triggers":[{"type": "ImageChange", "imageChangeParams":{"from":{"name":"mn-benefits:${{ needs.draft-release.outputs.tag_name }}"}, "containerNames":["mn-benefits-atst"]}}]}}'
oc rollout latest dc/mn-benefits-atst
- name: Announce success on Teams
if: ${{ job.status == 'success' }}
uses: jdcargile/ms-teams-notification@v1.4
with:
github-token: ${{ github.token }} # this will use the runner's token.
ms-teams-webhook-uri: ${{ secrets.MS_TEAMS_WEBHOOK_URI }}
notification-summary: Deploy to MNbenefits ATST succeeded, status - ${{ job.status }}
# color is green
notification-color: 008000
timezone: America/Chicago
- name: Announce fail on Teams
if: ${{ job.status != 'success' }}
uses: jdcargile/ms-teams-notification@v1.4
with:
github-token: ${{ github.token }} # this will use the runner's token.
ms-teams-webhook-uri: ${{ secrets.MS_TEAMS_WEBHOOK_URI }}
notification-summary: Deploy to MNbenefits ATST failed, status - ${{ job.status }}
# color is red
notification-color: ff0000
timezone: America/Chicago