PIMS-1343/1344: Properties Data UI Changes #21
Workflow file for this run
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
# GitHub Actions workflow for deploying APP image on PR merge to main branch | |
name: REACT APP - DEV Deploy | |
on: | |
pull_request: | |
types: | |
- closed | |
branches: [main] | |
paths: | |
- 'react-app/**' # Triggers on changes to files in the frontend/ directory. | |
workflow_dispatch: | |
inputs: | |
image_tag: | |
description: 'Image Tag to deploy' | |
required: true | |
env: | |
IMAGE_TAG: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.image_tag || github.event.pull_request.number }} | |
jobs: | |
# Job to deploy APP image to OpenShift | |
Deploy-To-OpenShift: | |
if: ${{ github.event_name == 'workflow_dispatch' || github.event.pull_request.merged }} | |
name: Deploy to OpenShift | |
runs-on: ubuntu-latest | |
steps: | |
# Checkout the repository | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
# Login to OpenShift | |
- name: Login to OpenShift | |
uses: redhat-actions/oc-login@v1 | |
with: | |
openshift_server_url: ${{ secrets.OPENSHIFT_SERVER_URL }} | |
openshift_token: ${{ secrets.OPENSHIFT_SA_DEV_TOKEN }} | |
namespace: ${{ secrets.OPENSHIFT_DEV_NAMESPACE }} | |
# Process and Apply APP DeploymentConfig | |
- name: Process and Apply APP DeploymentConfig | |
env: | |
NAMESPACE: "${{ secrets.OPENSHIFT_DEV_NAMESPACE }}" | |
DC_TEMPLATE: "app-v2-dc-template.yaml" | |
IMAGE_TAG: ${{ env.IMAGE_TAG }} | |
ENVIRONMENT: "dev" | |
APPLICATION_NAME: "pims-app-v2" | |
LICENSE_PLATE: "${{ secrets.LICENSE_PLATE }}" | |
run: | | |
./.github/helpers/deploy.sh | |
# Job to check the health of the deployed APP | |
Health-Check: | |
name: Check Deployment Health | |
runs-on: ubuntu-latest | |
needs: [ Deploy-To-OpenShift ] | |
steps: | |
# Login to OpenShift | |
- name: Login to OpenShift | |
uses: redhat-actions/oc-login@v1 | |
env: | |
OPENSHIFT_USER: github-actions | |
OPENSHIFT_PROJECT: ${{ secrets.OPENSHIFT_DEV_NAMESPACE }} | |
with: | |
openshift_server_url: ${{ secrets.OPENSHIFT_SERVER_URL }} | |
openshift_token: ${{ secrets.OPENSHIFT_SA_DEV_TOKEN }} | |
namespace: ${{ secrets.OPENSHIFT_DEV_NAMESPACE }} | |
# Check Deployment Status | |
- name: Check Deployment Status | |
run: | | |
oc rollout status -n ${{ secrets.OPENSHIFT_DEV_NAMESPACE }} dc/pims-app-v2 --watch | |
# Job to clean up previous objects in OpenShift | |
Clean-Up: | |
name: Clean Up | |
runs-on: ubuntu-latest | |
needs: [ Health-Check ] | |
steps: | |
# Login to OpenShift | |
- name: Login to OpenShift | |
uses: redhat-actions/oc-login@v1 | |
env: | |
OPENSHIFT_USER: github-actions | |
OPENSHIFT_PROJECT: ${{ secrets.OPENSHIFT_DEV_NAMESPACE }} | |
with: | |
openshift_server_url: ${{ secrets.OPENSHIFT_SERVER_URL }} | |
openshift_token: ${{ secrets.OPENSHIFT_SA_DEV_TOKEN }} | |
namespace: ${{ secrets.OPENSHIFT_DEV_NAMESPACE }} | |
# Remove previous objects | |
- name: Remove previous objects | |
run: | | |
oc delete pod -n ${{ secrets.OPENSHIFT_DEV_NAMESPACE }} --field-selector status.phase=Succeeded | |
# Remove previous replication controllers | |
- name: Remove previous replication controllers | |
run: | | |
oc delete rc -n ${{ secrets.OPENSHIFT_DEV_NAMESPACE }} --field-selector status.replicas=0 | |
# Job to update the wiki with deployed image tag information | |
Update_Wiki_Tags: | |
needs: [ Health-Check ] | |
name: Update table in wiki | |
runs-on: ubuntu-latest | |
env: | |
GH_TOKEN: ${{ github.token }} | |
steps: | |
# Checkout the repository | |
- name: Checkout | |
uses: actions/checkout@v3 | |
# Clone wiki repository | |
- name: Clone wiki repository | |
run: | | |
echo "Cloning wiki repo https://github.com/$GITHUB_REPOSITORY.wiki.git" | |
git clone "https://$GITHUB_ACTOR:[email protected]/$GITHUB_REPOSITORY.wiki.git" ./wiki | |
# Setup Python | |
- name: Setup Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' | |
# Run update wiki python script | |
- name: Run update wiki python script | |
run: python ./.github/helpers/update-wiki-table.py ./wiki/Image-tags.md "APP V2" "Deployed Image Tag in DEV" "${{ env.IMAGE_TAG }}" | |
# Commit and push changes to wiki | |
- name: Commit and push changes to wiki | |
run: | | |
cd ./wiki | |
git config user.name "$GITHUB_ACTOR" | |
git config user.email "[email protected]" | |
git add . | |
if git diff-index --quiet HEAD; then | |
echo "Nothing changed" | |
exit 0 | |
fi | |
echo "Pushing changes to wiki" | |
git commit -m "Value populated at Deploy App" && git push "https://$GITHUB_ACTOR:[email protected]/$GITHUB_REPOSITORY.wiki.git" | |