This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
name: Checkout Code Template
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
target_branch:
|
||||
description: 'Target branch to clone'
|
||||
required: true
|
||||
type: string
|
||||
git_repo_url:
|
||||
description: 'Git repository URL to clone from'
|
||||
required: true
|
||||
type: string
|
||||
deployment_env:
|
||||
description: 'Deployment environment name'
|
||||
required: true
|
||||
type: string
|
||||
tags_version:
|
||||
description: 'Tag version'
|
||||
required: true
|
||||
type: string
|
||||
secrets:
|
||||
GITLAB_TOKEN:
|
||||
required: true
|
||||
|
||||
jobs:
|
||||
checkout-and-verify:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Show Configuration
|
||||
run: |
|
||||
echo "Target Branch: ${{ inputs.target_branch }}"
|
||||
echo "Deployment Environment: ${{ inputs.deployment_env }}"
|
||||
echo "Tags Version: ${{ inputs.tags_version }}"
|
||||
|
||||
- name: Checkout Code from GitLab
|
||||
env:
|
||||
GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN }}
|
||||
run: |
|
||||
echo "Cloning branch '${{ inputs.target_branch }}'..."
|
||||
git clone --branch ${{ inputs.target_branch }} https://oauth2:${GITLAB_TOKEN}@${{ inputs.git_repo_url }} .
|
||||
|
||||
- name: Verify Code Checkout
|
||||
run: |
|
||||
echo "Successfully checked out target branch!"
|
||||
ls -la
|
||||
@@ -0,0 +1,59 @@
|
||||
name: Load Environment Template
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
target_branch:
|
||||
description: 'Branch name to evaluate'
|
||||
required: true
|
||||
type: string
|
||||
outputs:
|
||||
deployment_env:
|
||||
description: 'The resolved deployment environment'
|
||||
value: ${{ jobs.load-environment.outputs.deployment_env }}
|
||||
tags_version:
|
||||
description: 'The resolved tag version'
|
||||
value: ${{ jobs.load-environment.outputs.tags_version }}
|
||||
target_branch:
|
||||
description: 'The confirmed target branch'
|
||||
value: ${{ jobs.load-environment.outputs.target_branch }}
|
||||
|
||||
jobs:
|
||||
load-environment:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
deployment_env: ${{ env.DEPLOYMENT_ENV }}
|
||||
tags_version: ${{ env.TAGS_VERSION }}
|
||||
target_branch: ${{ env.TARGET_BRANCH }}
|
||||
steps:
|
||||
- name: Load Environment Variables
|
||||
run: |
|
||||
BRANCH_NAME="${{ inputs.target_branch }}"
|
||||
echo "Building branch is: $BRANCH_NAME"
|
||||
echo "TARGET_BRANCH=$BRANCH_NAME" >> $GITHUB_ENV
|
||||
|
||||
if [ "$BRANCH_NAME" = "develop" ]; then
|
||||
echo "Deploying Code to the development environment"
|
||||
echo "DEPLOYMENT_ENV=development" >> $GITHUB_ENV
|
||||
echo "TAGS_VERSION=minor" >> $GITHUB_ENV
|
||||
elif [ "$BRANCH_NAME" = "main" ] || [ "$BRANCH_NAME" = "prod" ]; then
|
||||
echo "Deploying Code to the production environment"
|
||||
echo "DEPLOYMENT_ENV=production" >> $GITHUB_ENV
|
||||
echo "TAGS_VERSION=major" >> $GITHUB_ENV
|
||||
elif [ "$BRANCH_NAME" = "test" ] || [ "$BRANCH_NAME" = "testing" ]; then
|
||||
echo "Deploying Code to the testing environment"
|
||||
echo "DEPLOYMENT_ENV=test" >> $GITHUB_ENV
|
||||
echo "TAGS_VERSION=test" >> $GITHUB_ENV
|
||||
elif [ "$BRANCH_NAME" = "uat" ]; then
|
||||
echo "Deploying Code to the falak temp cluster"
|
||||
echo "DEPLOYMENT_ENV=falak" >> $GITHUB_ENV
|
||||
echo "TAGS_VERSION=uat" >> $GITHUB_ENV
|
||||
elif [ "$BRANCH_NAME" = "cib-seven" ]; then
|
||||
echo "Deploying Code to the cib temp cluster"
|
||||
echo "DEPLOYMENT_ENV=cib" >> $GITHUB_ENV
|
||||
echo "TAGS_VERSION=cib" >> $GITHUB_ENV
|
||||
else
|
||||
echo "Deploying Code to default environment"
|
||||
echo "DEPLOYMENT_ENV=default" >> $GITHUB_ENV
|
||||
echo "TAGS_VERSION=latest" >> $GITHUB_ENV
|
||||
fi
|
||||
Reference in New Issue
Block a user