Deploy #75
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: 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: ibn40 | |
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: ibn40 | |
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: | |
clone: | |
runs-on: private-2 | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
repository: IndustryFusion/IfricPlatform | |
ref: main | |
path: IfricPlatform | |
token: ${{ secrets.PRIVATE_GITHUB_TOKEN }} | |
build: | |
runs-on: private-2 | |
needs: clone | |
env: | |
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} | |
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} | |
DOCKER_PREFIX: ${{ secrets.DOCKER_PREFIX }} | |
outputs: | |
DOCKER_TAG: ${{ steps.build.outputs.NIGHTLY_DOCKER_TAG }} | |
steps: | |
- id: build | |
name: Build & Push Image | |
shell: bash | |
run: | | |
export DOCKER_TAG="latest" | |
NIGHTLY_DOCKER_TAG=nightly-`date -I`-`date +%s` | |
docker login -u "${DOCKER_USERNAME}" -p "${DOCKER_PASSWORD}" | |
docker-compose 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}" | |
deploy-action: | |
runs-on: private-2 | |
container: | |
image: ifx40/deployer:${{ inputs.CLUSTER }} | |
options: --user root | |
volumes: | |
- ${{ github.workspace }}/GitOpsRepo:/home/deployer/GitOpsRepo | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.ref }} | |
repository: IndustryFusion/GitOpsRepo | |
- name: List directory contents | |
run: | | |
ls -la /home/deployer/GitOpsRepo | |
- 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 -l app=ifric-platform apply \ | |
--set mainRepo=${{ inputs.DOCKER_REGISTRY }} \ | |
--set mainVersion=${{ inputs.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 }}" \ |