PRIME-2360 Community Site and HA Site Snapshot #1034
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: Build & Deploy Backup - Develop | |
on: | |
pull_request: # remove after pr is approved / before pr is merged | |
workflow_dispatch: | |
push: | |
branches: | |
- develop | |
paths: | |
- prime-database-backup/** | |
- .github/workflows/build-deploy-backup-dev.yml | |
env: | |
NAME: backup | |
INITIAL_TAG: latest | |
TAG: dev | |
CONTEXT: prime-database-backup/ | |
jobs: | |
build-backup: | |
runs-on: ubuntu-20.04 | |
environment: Development | |
steps: | |
- name: "Checkout the repo" | |
uses: actions/checkout@v3 | |
- name: "Login to OpenShift repository" | |
uses: docker/login-action@v2 | |
with: | |
registry: ${{secrets.OPENSHIFT_IMAGE_REPOSITORY}} | |
username: ${{secrets.OPENSHIFT_TOOLS_SERVICE_ACCOUNT_USERNAME}} | |
password: ${{secrets.OPENSHIFT_TOOLS_SERVICE_ACCOUNT_PASSWORD}} | |
- name: "Build Backup image" | |
run: | | |
docker build -t ${{ env.NAME }}:${{ env.INITIAL_TAG }} ${{ env.CONTEXT }} -f ${{ env.CONTEXT }}openshift.dockerfile | |
- name: "Docker tag and push Backup image" | |
run: | | |
docker tag ${{ env.NAME }}:${{ env.INITIAL_TAG }} ${{secrets.OPENSHIFT_IMAGE_REPOSITORY}}/${{secrets.OPENSHIFT_LICENSE_PLATE}}-tools/${{ env.NAME }}:${{ env.INITIAL_TAG }} | |
docker tag ${{ env.NAME }}:${{ env.INITIAL_TAG }} ${{secrets.OPENSHIFT_IMAGE_REPOSITORY}}/${{secrets.OPENSHIFT_LICENSE_PLATE}}-tools/${{ env.NAME }}:${{ env.TAG }} | |
docker push ${{secrets.OPENSHIFT_IMAGE_REPOSITORY}}/${{secrets.OPENSHIFT_LICENSE_PLATE}}-tools/${{ env.NAME }}:${{ env.TAG }} | |
apply-oc-template: | |
runs-on: ubuntu-20.04 | |
environment: Development | |
needs: [build-backup] | |
steps: | |
- name: "Use the OpenShift template" | |
uses: actions/checkout@v3 | |
- name: Install OC | |
uses: redhat-actions/openshift-tools-installer@v1 | |
with: | |
oc: "4.6" | |
- name: Authenticate and set context | |
uses: redhat-actions/oc-login@v1.1 | |
with: | |
openshift_server_url: ${{secrets.OPENSHIFT_SERVER_URL}} | |
openshift_token: ${{secrets.OPENSHIFT_SERVICE_TOKEN}} | |
namespace: ${{secrets.OPENSHIFT_LICENSE_PLATE}}-${{secrets.OPENSHIFT_ENVIRONMENT}} | |
- name: "Process template" | |
id: oc | |
run: | | |
oc process -f infrastructure/backup-container.yml \ | |
-p NAME=backup \ | |
-p SOURCE_CONTEXT_DIR=prime-database-backup \ | |
-p SOURCE_REPOSITORY_URL=https://github.com/bcgov/moh-prime \ | |
-p OC_NAMESPACE=${{secrets.OPENSHIFT_LICENSE_PLATE}} \ | |
-p OC_APP=dev \ | |
-p POSTGRESQL_HOST=postgresql \ | |
-p METABASE_HOST=metabase-database | oc apply -n ${{secrets.OPENSHIFT_LICENSE_PLATE}}-${{secrets.OPENSHIFT_ENVIRONMENT}} -f - |