Zeva new-pipeline Test CI #5
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
## For each release, the value of workflow name, branches and VERSION need to be adjusted accordingly | |
name: ZEVA new-pipeline-1.63.0 Test CI | |
on: | |
workflow_dispatch: | |
env: | |
VERSION: 1.63.0 | |
GIT_URL: https://github.com/bcgov/zeva.git | |
DEV_NAMESPACE: ${{ secrets.OPENSHIFT_NAMESPACE_PLATE }}-dev | |
TEST_NAMESPACE: ${{ secrets.OPENSHIFT_NAMESPACE_PLATE }}-test | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
set-pre-release: | |
name: Find Dev deployment pre-release number | |
runs-on: ubuntu-latest | |
outputs: | |
output1: ${{ steps.set-pre-release.outputs.PRE_RELEASE }} | |
steps: | |
- name: Log in to Openshift | |
uses: redhat-actions/[email protected] | |
with: | |
openshift_server_url: ${{ secrets.OPENSHIFT_SERVER }} | |
openshift_token: ${{ secrets.OPENSHIFT_TOKEN }} | |
insecure_skip_tls_verify: true | |
namespace: ${{ env.DEV_NAMESPACE }} | |
- id: set-pre-release | |
run: | | |
check_string() { | |
local string="$1" | |
if [ ${#string} -ne 14 ]; then | |
echo "String length must be 14 characters" | |
return 1 | |
fi | |
if ! [[ $string =~ ^[0-9]+$ ]]; then | |
echo "String can only contain numbers" | |
return 1 | |
fi | |
local year="${string:0:4}" | |
local month="${string:4:2}" | |
local day="${string:6:2}" | |
local hour="${string:8:2}" | |
local minute="${string:10:2}" | |
local second="${string:12:2}" | |
if ! date -d "$year-$month-$day $hour:$minute:$second" &> /dev/null; then | |
echo "String format must be yyyymmddhhmmss" | |
return 1 | |
fi | |
return 0 | |
} | |
input_string=$(oc -n ${{ env.DEV_NAMESPACE }} describe deployment/zeva-dev-frontend | grep Image | awk -F '-' '{print $NF}') | |
echo "The retrieved pre-release number on Dev is $input_string " | |
if check_string "$input_string"; then | |
echo "It is valid" | |
echo "PRE_RELEASE=$input_string" >> $GITHUB_OUTPUT | |
else | |
echo "It is not valid" | |
exit 1 | |
fi | |
deploy-on-test: | |
name: Deploy ZEVA on Test | |
runs-on: ubuntu-latest | |
timeout-minutes: 60 | |
needs: [set-pre-release] | |
env: | |
PRE_RELEASE: ${{ needs.set-pre-release.outputs.output1 }} | |
steps: | |
- name: Ask for approval for ZEVA release-${{ env.VERSION }} Test deployment | |
uses: trstringer/[email protected] | |
with: | |
secret: ${{ github.TOKEN }} | |
approvers: emi-hi,tim738745,kuanfandevops,JulianForeman,rogerlcleung | |
minimum-approvals: 1 | |
issue-title: "ZEVA ${{ env.VERSION }}-${{ env.PRE_RELEASE }} Test Deployment" | |
- name: Checkout Manifest repository | |
uses: actions/[email protected] | |
with: | |
repository: bcgov-c/tenant-gitops-e52f12 | |
ref: main | |
ssh-key: ${{ secrets.MANIFEST_REPO_DEPLOY_KEY }} | |
- name: Update frontend and backend image tags | |
uses: mikefarah/[email protected] | |
with: | |
cmd: | | |
yq -i '.frontend.image.tag = "${{ env.VERSION }}-${{ env.PRE_RELEASE }}"' zeva/values-test.yaml | |
yq -i '.backend.image.tag = "${{ env.VERSION }}-${{ env.PRE_RELEASE }}"' zeva/values-test.yaml | |
- name: GitHub Commit & Push | |
run: | | |
git config --global user.email "[email protected]" | |
git config --global user.name "GitHub Actions" | |
git add zeva/values-test.yaml | |
git commit -m "Update the image tag to ${{ env.VERSION }}-${{ env.PRE_RELEASE }} on Zeva Test Environment" | |
git push | |
- name: Log in to Openshift | |
uses: redhat-actions/[email protected] | |
with: | |
openshift_server_url: ${{ secrets.OPENSHIFT_SERVER }} | |
openshift_token: ${{ secrets.OPENSHIFT_TOKEN }} | |
insecure_skip_tls_verify: true | |
namespace: ${{ env.DEV_NAMESPACE }} | |
- name: Tag ZEVA images to Test | |
run: | | |
helm -n ${{ env.DEV_NAMESPACE }} list | |
oc tag ${{ env.DEV_NAMESPACE }}/zeva-backend:${{ env.VERSION }}-${{ env.PRE_RELEASE }} ${{ env.TEST_NAMESPACE }}/zeva-backend:${{ env.VERSION }}-${{ env.PRE_RELEASE }} | |
oc tag ${{ env.DEV_NAMESPACE }}/zeva-frontend:${{ env.VERSION }}-${{ env.PRE_RELEASE }} ${{ env.TEST_NAMESPACE }}/zeva-frontend:${{ env.VERSION }}-${{ env.PRE_RELEASE }} | |
cd zeva | |
helm -n ${{ env.DEV_NAMESPACE }} -f ./values-dev.yaml upgrade --install zeva-dev . |