Skip to content

Merge pull request #1494 from bcgov/UTOPIA-1389-b #75

Merge pull request #1494 from bcgov/UTOPIA-1389-b

Merge pull request #1494 from bcgov/UTOPIA-1389-b #75

name: EMERALD - Push API to Artifactory
on:
push:
branches: [ main ]
paths:
- "src/backend/**"
workflow_dispatch:
jobs:
DPIA-API-Build-Tag-Push:
environment: API-Dev
runs-on: ubuntu-latest
steps:
# Checkout CIRMO-DPIA Github Repository
- name: Checkout Repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Login to Artifactory to Pull Images in S2I Build
uses: redhat-actions/podman-login@v1
with:
registry: ${{ secrets.ARTPROJ_PROJECT_URL }}
username: ${{ secrets.ARTPROJ_SA_USERNAME }}
password: ${{ secrets.ARTPROJ_SA_PASSWORD }}
# Setup environment variables
- name: Setup environment
run: |
make api-setup-env
# Build the DPIA API Application Image via docker-compose
- name: Build the Docker image
run: |
docker-compose build dpia-api
# TROUBLESHOOTING - view images present in github action run
- name: Docker List Images
run: |
docker image ls
# Tag Docker Image built with prod
- name: Docker Tag Version
run: |
docker tag cirmo-dpia_dpia-api ${{ secrets.ARTPROJ_PROJECT_URL }}/daa7-dpia-image-repository/api-dev:latest
# Push docker image to BC Gov Repository
- name: Docker Push Version
run: |
docker push ${{ secrets.ARTPROJ_PROJECT_URL }}/daa7-dpia-image-repository/api-dev:latest
DEV-deploy:
runs-on: ubuntu-latest
environment: API-Dev
needs: [ DPIA-API-Build-Tag-Push ]
steps:
# Checkout Repository
- name: Checkout Repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Trigger Tekton Pipeline Deployment
env:
ENVIRONMENT: dev
APPLICATION: dpia-api
IMAGE: 'api-dev:latest'
TEMPLATE_URL: ${{ secrets.TEMPLATEURL }}
EL_ROUTE: ${{ secrets.EL_ROUTE }}
run: |
./.github/helpers/trigger-tekton.sh
# TODO Build health check in tekton
# TODO Build Cleanup in tekton
#DEV-Success-Notify:
# runs-on: ubuntu-latest
# environment: API-Dev
# needs: [ DEV-cleanup ]
# steps:
# - name: Message Teams Channel on Success
# run: |
# curl --location --request POST ${{ secrets.TEAMS_SUCCESS_URL }} \
# --header 'Content-Type: text/plain' \
# --data-raw '{
# "@context": "https://schema.org/extensions",
# "@type": "MessageCard",
# "themeColor": "0072C6",
# "title": "SUCCESS! API Deployment to PIA ${{ secrets.ENVIRONMENT }} Environment has finished.",
# "text": "The PIA API has been built and deployed to the ${{ secrets.ENVIRONMENT }} environment. \n\n The logs for the successful deployment can be found [here](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})\n\n The changes for commit ${{ github.sha }} can be found [here](https://dev.pia.gov.bc.ca/api/api-docs).",
# }'
#DEV-Failure-Notify:
# runs-on: ubuntu-latest
# environment: API-Dev
# if: failure()
# steps:
# - name: Message Teams Channel on Failure
# run: |
# curl --location --request POST ${{ secrets.TEAMS_FAILURE_URL }} \
# --header 'Content-Type: text/plain' \
# --data-raw '{
# "@context": "https://schema.org/extensions",
# "@type": "MessageCard",
# "themeColor": "0072C6",
# "title": "FAILURE! API Deployment to the PIA ${{ secrets.ENVIRONMENT }} Environment has failed.",
# "text": "The PIA API has NOT been built and deployed to the ${{ secrets.LICENSE_PLATE }} ${{ secrets.ENVIRONMENT }} environment.\n\n Please review the Github Action for this deployment (here)[${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}].",
# }'