Feat/40 zxs data #4
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: Pull Request Closed | |
on: | |
pull_request: | |
types: | |
- closed | |
workflow_dispatch: | |
jobs: | |
# Clean up OpenShift when PR closed, no conditions | |
cleanup-openshift: | |
name: Cleanup OpenShift | |
runs-on: ubuntu-22.04 | |
environment: dev | |
steps: | |
- name: Log in and set context | |
uses: redhat-actions/oc-login@v1 | |
with: | |
openshift_server_url: ${{ vars.OC_SERVER }} | |
openshift_token: ${{ secrets.OC_TOKEN }} | |
namespace: ${{ vars.OC_NAMESPACE }} | |
- name: Calculate Zone | |
id: calculateZone | |
shell: bash | |
run: | | |
event_num=${{ github.event.number }} | |
if [[ -z "${event_num// }" ]]; then | |
zone=pr-999 | |
else | |
zone=pr-$event_num | |
fi | |
echo zone: $zone | |
echo "ZONE=$zone" >> $GITHUB_ENV | |
- name: Uninstall helm chart | |
run: | | |
helm uninstall climateobs-${{ env.ZONE }} | |
# If merged into main, then handle any image promotions | |
image-promotions: | |
name: Image Promotions | |
# TODO: uncomment once working | |
if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'main' | |
runs-on: ubuntu-22.04 | |
environment: prod | |
permissions: | |
packages: write | |
steps: | |
# to help debug this action, logic to get the sha depending | |
# on different trigger types. | |
- name: Calculate Repo Commit Sha | |
id: calcRepoCommitSha | |
shell: bash | |
run: | | |
event_num=${{ github.event.number }} | |
if [[ -z "${event_num// }" ]]; then | |
sha=${{ github.event.push.head.sha }} | |
else | |
sha=${{ github.event.pull_request.head.sha }} | |
fi | |
echo sha: $sha | |
echo "COMMIT_SHA=$sha" >> $GITHUB_ENV | |
- uses: actions/checkout@v3 | |
id: checkout | |
with: | |
ref: ${{ env.COMMIT_SHA }} | |
- name: Log in and set context | |
uses: redhat-actions/oc-login@v1 | |
with: | |
openshift_server_url: ${{ vars.OC_SERVER }} | |
openshift_token: ${{ secrets.OC_TOKEN }} | |
namespace: ${{ vars.OC_NAMESPACE }} | |
- name: Upgrade chart | |
id: upgradeHelmChart | |
shell: bash | |
env: | |
OBJ_STORE_BUCKET: ${{ secrets.OBJ_STORE_BUCKET }} | |
OBJ_STORE_SECRET: ${{ secrets.OBJ_STORE_SECRET }} | |
OBJ_STORE_USER: ${{ secrets.OBJ_STORE_USER }} | |
OBJ_STORE_HOST: ${{ vars.OBJ_STORE_HOST }} | |
run: | | |
cd cicd | |
zone=prod | |
imagetag=pr-${{ github.event.number }} | |
echo Running Helm Chart | |
# run helm | |
# --------------------------------- | |
helm upgrade --install climateobs-$zone climateobs \ | |
--set obj_store.bucket=${{ env.OBJ_STORE_BUCKET }} \ | |
--set obj_store.host=${{ vars.OBJ_STORE_HOST }} \ | |
--set obj_store.user_id=${{ env.OBJ_STORE_USER }} \ | |
--set obj_store.secret=${{ env.OBJ_STORE_SECRET }} \ | |
--set firedata_image.promote=bcgov/firedata_pipe:$imagetag \ | |
--set app.zone=$zone \ | |
--set climateobs_job.climateobs_mnt_point=/data | |
echo Helm Chart Complete |