Skip to content

Deploy

Deploy #96

Workflow file for this run

name: Prod-Deploy
on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
inputs:
APPS:
description: 'Space-separated list of apps to deploy/upgrade, leave empty to deploy everything'
required: false
default: ''
type: string
NAMESPACE:
description: 'Namespace to deploy'
required: true
type: string
DOCKER_REGISTRY:
description: 'Name of the docker registry'
required: false
default: ifx40
type: string
DOCKER_TAG:
description: 'Docker tag to use in the deployment'
required: false
default: 'latest'
type: string
PULL_SECRET_CREDENTIALS:
description: 'Name of the secret in cluster that contains docker registry credentials'
required: false
default: 'regcred'
type: string
CLUSTER:
description: 'Tag of the deployer image with the Kubernetes cluster config'
required: true
type: string
workflow_call:
inputs:
APPS:
description: 'Space-separated list of apps to deploy/upgrade, leave empty to deploy everything'
required: false
default: ''
type: string
NAMESPACE:
description: 'Namespace to deploy'
required: true
type: string
DOCKER_REGISTRY:
description: 'Name of the docker registry'
required: false
default: ifx40
type: string
DOCKER_TAG:
description: 'Docker tag to use in the deployment'
required: false
default: 'latest'
type: string
PULL_SECRET_CREDENTIALS:
description: 'Name of the secret in cluster that contains docker registry credentials'
required: false
default: 'regcred'
type: string
CLUSTER:
description: 'Tag of the deployer image with the Kubernetes cluster config'
required: true
type: string
secrets:
PRIVATE_GITHUB_TOKEN:
description: 'Token to use to clone the repositories'
required: true
S3_URL:
description: 'S3 url to use in the cluster'
required: false
S3_ACCESS_KEY:
description: 'S3 access key to use in the cluster'
required: false
S3_SECRET_KEY:
description: 'S3 secret key to use in the cluster'
required: false
HUB_TOKEN:
description: ''
required: false
GATEWAY_TOKEN:
description: ''
required: false
ALERTA_KEY_DEV:
description: ''
required: false
FACTORY_MONGO_URL_DEV:
description: ''
required: false
USERNAME:
description: ''
required: false
PASSWORD:
description: ''
required: false
ICID_MONGO_URL_DEV:
description: ''
required: false
CLIENT_ID:
description: ''
required: false
CLIENT_SECRET:
description: ''
required: false
EMAIL_URL:
description: ''
required: false
MONGO_URL:
description: ''
required: false
TENANT_ID:
description: ''
required: false
ICID_NAMESPACE:
description: ''
required: false
CREATOR_MONGO_URL_DEV:
description: ''
required: false
TEMPLATE_MONGO_URL_DEV:
description: ''
required: false
jobs:
build:
runs-on: private-2
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
DOCKER_PREFIX: docker.io/ifx40
outputs:
DOCKER_TAG: ${{ steps.build.outputs.NIGHTLY_DOCKER_TAG }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
repository: IndustryFusion/IfricPlatform
ref: main
path: IfricPlatform
token: ${{ secrets.PRIVATE_GITHUB_TOKEN }}
- name: List directory contents
run: ls -la IfricPlatform
- id: build
name: Build & Push Image
shell: bash
run: |
cd IfricPlatform
export DOCKER_TAG="latest"
NIGHTLY_DOCKER_TAG=nightly-$(date -I)-$(date +%s)
docker login -u "${DOCKER_USERNAME}" -p "${DOCKER_PASSWORD}"
docker-compose -f docker-compose.yaml build
docker tag ${DOCKER_PREFIX}/ifric-platform-backend:${DOCKER_TAG} ${DOCKER_PREFIX}/ifric-platform-backend:${NIGHTLY_DOCKER_TAG}
docker tag ${DOCKER_PREFIX}/ifric-platform-frontend:${DOCKER_TAG} ${DOCKER_PREFIX}/ifric-platform-frontend:${NIGHTLY_DOCKER_TAG}
docker push ${DOCKER_PREFIX}/ifric-platform-backend:${DOCKER_TAG}
docker push ${DOCKER_PREFIX}/ifric-platform-backend:${NIGHTLY_DOCKER_TAG}
docker push ${DOCKER_PREFIX}/ifric-platform-frontend:${DOCKER_TAG}
docker push ${DOCKER_PREFIX}/ifric-platform-frontend:${NIGHTLY_DOCKER_TAG}
docker rmi ${DOCKER_PREFIX}/ifric-platform-backend:${DOCKER_TAG}
docker rmi ${DOCKER_PREFIX}/ifric-platform-backend:${NIGHTLY_DOCKER_TAG}
docker rmi ${DOCKER_PREFIX}/ifric-platform-frontend:${DOCKER_TAG}
docker rmi ${DOCKER_PREFIX}/ifric-platform-frontend:${NIGHTLY_DOCKER_TAG}
echo "NIGHTLY_DOCKER_TAG=${NIGHTLY_DOCKER_TAG}" >> "${GITHUB_OUTPUT}"
clone-repo:
runs-on: private-2
steps:
- uses: actions/checkout@v3
with:
repository: IndustryFusion/GitOpsRepo.git
ref: ${{ github.ref }}
path: GitOpsRepo
#token: ${{ secrets.PRIVATE_GITHUB_TOKEN }}
deploy-action:
needs: [clone-repo, build]
runs-on: private-2
container:
image: ifx40/deployer:${{ inputs.CLUSTER }}
options: --user root
volumes:
- ${{ github.workspace }}/GitOpsRepo:/home/deployer/GitOpsRepo
steps:
- name: Deploy
run: |
helm plugin list
#export NAMESPACE="${{ inputs.NAMESPACE }}"
cd /home/deployer/GitOpsRepo/helm
#bash install_operators.sh
APPS="${{ inputs.APPS }}"
LABEL_ARG=""
for app in ${APPS}; do
echo "Adding app: ${app} to deployment"
LABEL_ARG="${LABEL_ARG} -l app=${app}"
done
echo "Deploying with selector: ${LABEL_ARG}"
helmfile ${LABEL_ARG} apply \
--set mainRepo=${{ inputs.DOCKER_REGISTRY }} \
--set mainVersion=${{ needs.build.outputs.DOCKER_TAG }} \
--set namespace=${{ inputs.NAMESPACE }} \
--set pullSecretCredentials=${{ inputs.PULL_SECRET_CREDENTIALS }} \
--set ifric_platform.githubToken="${{ secrets.HUB_TOKEN }}" \
--set ifric_platform.s3AccessKey="${{ secrets.S3_ACCESS_KEY }}" \
--set ifric_platform.s3SecretKey="${{ secrets.S3_SECRET_KEY }}" \
--set ifric_platform.mongoUrl="${{ secrets.CREATOR_MONGO_URL_DEV }}" \
--set ifric_platform_temp.githubToken="${{ secrets.HUB_TOKEN }}" \