Deploy to MNbenefits DEV #1375
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
# This workflow will build a Java project with Gradle | |
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle | |
# For more information regarding posting announcements to MS Teams see: https://github.com/marketplace/actions/microsoft-teams-notification | |
name: Deploy to MNbenefits DEV | |
on: | |
workflow_run: | |
workflows: ["Run tests"] | |
branches: [main] | |
types: | |
- completed | |
workflow_dispatch: | |
inputs: { } | |
jobs: | |
announce_failure: | |
name: Announce test failure on Teams | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Announce on Teams | |
if: ${{ github.event.workflow_run.conclusion == 'failure' }} | |
uses: jdcargile/[email protected] | |
with: | |
github-token: ${{ github.token }} # this will use the runner's token. | |
ms-teams-webhook-uri: ${{ secrets.MS_TEAMS_WEBHOOK_URI }} | |
notification-summary: MNbenefits tests failed in CI! | |
# color is red | |
notification-color: ff0000 | |
timezone: America/Chicago | |
mnitdeploy: | |
if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
name: deploy to MNbenefits DEV | |
runs-on: ubuntu-22.04 | |
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 start-build mn-benefits --follow | |
- name: Announce success on Teams | |
if: ${{ job.status == 'success' }} | |
uses: jdcargile/[email protected] | |
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 DEV succeeded, status - ${{ job.status }} | |
# color is green | |
notification-color: 008000 | |
timezone: America/Chicago | |
- name: Announce fail on Teams | |
if: ${{ job.status != 'success' }} | |
uses: jdcargile/[email protected] | |
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 DEV failed, status - ${{ job.status }} | |
# color is red | |
notification-color: ff0000 | |
timezone: America/Chicago | |
merge_to_staging: | |
needs: mnitdeploy | |
if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
name: Merge main -> staging | |
runs-on: ubuntu-22.04 | |
permissions: write-all | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: '0' | |
ref: main | |
- uses: MaximeHeckel/[email protected] | |
with: | |
branchtomerge: main | |
branch: staging | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
evaluate_workflow: | |
needs: [mnitdeploy, merge_to_staging] | |
name: evaluate workflow | |
runs-on: ubuntu-lates | |
permissions: write-all | |
if: | | |
always() && | |
(needs.mnitdeploy.result == 'skipped' || needs.merge_to_staging == 'skipped') | |
steps: | |
- name: force workflow failure | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
core.setFailed('One or more required workflow jobs were skipped') | |