Improve performance (#140) #318
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: CD/CD Pipeline to DEV | |
env: | |
# Artifactory - can't get this to work yet | |
# DOCKER_ARTIFACTORY_REPO: artifacts.developer.gov.bc.ca/docker-remote | |
# ARTIFACTORY_REPO: artifacts.developer.gov.bc.ca | |
# IMAGE_REGISTRY: ${{ secrets.IMAGE_REGISTRY }} | |
# IMAGE_REGISTRY_USER: ${{ secrets.IMAGE_REGISTRY_USER }} | |
# IMAGE_REGISTRY_PASSWORD: ${{ secrets.IMAGE_REGISTRY_PASSWORD }} | |
# Registries such as GHCR, Quay.io, and Docker Hub are supported. | |
IMAGE_REGISTRY: ghcr.io/${{ github.repository_owner }} | |
IMAGE_REGISTRY_USER: ${{ github.actor }} | |
IMAGE_REGISTRY_PASSWORD: ${{ github.token }} | |
API_IMAGE_NAME: api | |
DATA_SERVICE_IMAGE_NAME: data-service | |
APP_IMAGE_NAME: dashboard | |
DB_MIGRATION_IMAGE_NAME: db-migration | |
IMAGE_TAG: latest | |
DEPLOY_TO: dev | |
VERSION: 1.0.0 | |
on: | |
pull_request_target: | |
branches: | |
- dev | |
- main | |
types: | |
- closed | |
- opened | |
- reopened | |
- edited | |
push: | |
branches: | |
- dev | |
- main | |
jobs: | |
build-push: | |
name: Build and Push to Registry | |
runs-on: ubuntu-latest | |
outputs: | |
api: ${{ steps.filter.outputs.api }} | |
data-service: ${{ steps.filter.outputs.data-service }} | |
dashboard: ${{ steps.filter.outputs.dashboard }} | |
db-migration: ${{ steps.filter.outputs.db-migration }} | |
timeout-minutes: 10 | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout Source Code | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.event.pull_request.head.sha }} | |
- name: filter | |
uses: dorny/paths-filter@v3 | |
id: filter | |
with: | |
filters: | | |
api: | |
- 'src/api/**' | |
- 'src/libs/**' | |
data-service: | |
- 'src/data-service/**' | |
- 'src/libs/**' | |
dashboard: | |
- 'src/dashboard/**' | |
db-migration: | |
- 'src/libs/dal/**' | |
## BUILD | |
- name: Build API | |
id: build-api | |
uses: redhat-actions/[email protected] | |
if: ${{ steps.filter.outputs.api == 'true' || contains(github.event.pull_request.labels.*.name, 'api') }} | |
with: | |
image: ${{ github.event.repository.name }}/${{ env.API_IMAGE_NAME }} | |
tags: ${{ env.IMAGE_TAG }} ${{ env.VERSION }} ${{ env.DEPLOY_TO }} | |
context: . | |
dockerfiles: | | |
src/api/Dockerfile | |
- name: Build Data Service | |
id: build-data-service | |
uses: redhat-actions/[email protected] | |
if: ${{ steps.filter.outputs.data-service == 'true' || contains(github.event.pull_request.labels.*.name, 'data-service') }} | |
with: | |
image: ${{ github.event.repository.name }}/${{ env.DATA_SERVICE_IMAGE_NAME }} | |
tags: ${{ env.IMAGE_TAG }} ${{ env.VERSION }} ${{ env.DEPLOY_TO }} | |
context: . | |
dockerfiles: | | |
src/data-service/Dockerfile | |
- name: Build Dasbhoard | |
id: build-app | |
uses: redhat-actions/[email protected] | |
if: ${{ steps.filter.outputs.dashboard == 'true' || contains(github.event.pull_request.labels.*.name, 'dashboard') }} | |
with: | |
image: ${{ github.event.repository.name }}/${{ env.APP_IMAGE_NAME }} | |
tags: ${{ env.IMAGE_TAG }} ${{ env.VERSION }} ${{ env.DEPLOY_TO }} | |
context: src/dashboard | |
dockerfiles: | | |
src/dashboard/Dockerfile.prod | |
- name: Build DB Migration | |
id: build-db-migration | |
uses: redhat-actions/[email protected] | |
if: ${{ steps.filter.outputs.db-migration == 'true' || contains(github.event.pull_request.labels.*.name, 'db-migration') }} | |
with: | |
image: ${{ github.event.repository.name }}/${{ env.DB_MIGRATION_IMAGE_NAME }} | |
tags: ${{ env.IMAGE_TAG }} ${{ env.VERSION }} ${{ env.DEPLOY_TO }} | |
context: src/libs | |
dockerfiles: | | |
src/libs/Dockerfile | |
## PUSH TO REGISTRY | |
- name: Push API to registry | |
uses: redhat-actions/push-to-registry@v2 | |
if: ${{ steps.filter.outputs.api == 'true' || contains(github.event.pull_request.labels.*.name, 'api') }} | |
with: | |
image: ${{ steps.build-api.outputs.image }} | |
tags: ${{ steps.build-api.outputs.tags }} | |
registry: ${{ env.IMAGE_REGISTRY }} | |
username: ${{ env.IMAGE_REGISTRY_USER }} | |
password: ${{ env.IMAGE_REGISTRY_PASSWORD }} | |
- name: Push Data Service to registry | |
uses: redhat-actions/push-to-registry@v2 | |
if: ${{ steps.filter.outputs.data-service == 'true' || contains(github.event.pull_request.labels.*.name, 'data-service') }} | |
with: | |
image: ${{ steps.build-data-service.outputs.image }} | |
tags: ${{ steps.build-data-service.outputs.tags }} | |
registry: ${{ env.IMAGE_REGISTRY }} | |
username: ${{ env.IMAGE_REGISTRY_USER }} | |
password: ${{ env.IMAGE_REGISTRY_PASSWORD }} | |
- name: Push Dashboard to registry | |
uses: redhat-actions/push-to-registry@v2 | |
if: ${{ steps.filter.outputs.dashboard == 'true' || contains(github.event.pull_request.labels.*.name, 'dashboard') }} | |
with: | |
image: ${{ steps.build-app.outputs.image }} | |
tags: ${{ steps.build-app.outputs.tags }} | |
registry: ${{ env.IMAGE_REGISTRY }} | |
username: ${{ env.IMAGE_REGISTRY_USER }} | |
password: ${{ env.IMAGE_REGISTRY_PASSWORD }} | |
- name: Push DB Migration to registry | |
uses: redhat-actions/push-to-registry@v2 | |
if: ${{ steps.filter.outputs.db-migration == 'true' || contains(github.event.pull_request.labels.*.name, 'db-migration') }} | |
with: | |
image: ${{ steps.build-db-migration.outputs.image }} | |
tags: ${{ steps.build-db-migration.outputs.tags }} | |
registry: ${{ env.IMAGE_REGISTRY }} | |
username: ${{ env.IMAGE_REGISTRY_USER }} | |
password: ${{ env.IMAGE_REGISTRY_PASSWORD }} |