Skip to content

db-migrate-workflow-stage #10

db-migrate-workflow-stage

db-migrate-workflow-stage #10

name: db-migrate-workflow-stage
on:
workflow_dispatch:
inputs:
checkout_branch:
required: true
# type: choice
# options:
# - main
# - release/1.0
push:
branches:
- patch/dbmigrate
jobs:
build:
runs-on: ubuntu-latest
permissions: write-all
environment: stage
env:
checkout_branch: ${{ inputs.checkout_branch }}
DOCKER_IMAGE_NAME: db-migrate-image
DOCKER_CONTEXT_FOLDER: python
DOCKER_FILE: python/prohibition_web_svc/Dockerfile-migration
DOCKER_IMAGE_TAG: latest
namespace: test
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ inputs.checkout_branch }}
# ref: ${{ env.checkout_branch }}
- name: Setup
uses: docker/setup-buildx-action@v2
with:
install: true
- name: Login
uses: docker/login-action@v2
with:
registry: ${{ secrets.DOCKER_REGISTRY }}
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Tag
id: tag
uses: mathieudutour/github-tag-action@v6.1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
tag_prefix: ${{ env.DOCKER_IMAGE_NAME }}=v
fetch_all_tags: true
- name: Build
uses: docker/build-push-action@v3
with:
context: ${{ env.DOCKER_CONTEXT_FOLDER }}
file: ${{ env.DOCKER_FILE }}
push: true
tags: ${{ secrets.DOCKER_REGISTRY }}/dbe7-images/${{ env.DOCKER_IMAGE_NAME }}-stage:${{ env.DOCKER_IMAGE_TAG }}
- name: Authenticate and set context
uses: redhat-actions/oc-login@v1.2
with:
openshift_server_url: ${{ secrets.OPENSHIFT_SERVER_URL_SILVER }}
openshift_token: ${{ secrets.OPENSHIFT_SA_PIPELINE_TOKEN_SILVER_ENV }}
namespace: "${{ secrets.OPENSHIFT_LICENSE_PLATE_SILVER }}-test"
- name: Run Migration
run: |
oc delete job db-migrate-job --ignore-not-found=true
oc process -f migrate-job.yml --param IMAGE_NAME=${{ secrets.DOCKER_REGISTRY }}/dbe7-images/${{ env.DOCKER_IMAGE_NAME }}-stage:${{ env.DOCKER_IMAGE_TAG }} --param DB_HOST=${{ secrets.DB_HOST }} --param DB_NAME=${{ secrets.DB_NAME }} --param DB_PORT=${{ secrets.DB_PORT }} --param DB_USER=${{ secrets.DB_USER }} --param DB_PASS=${{ secrets.DB_PASS }} | oc apply -f -