From 885c5e121c2bcd7a71171acac9642a626cda9075 Mon Sep 17 00:00:00 2001 From: Mostafa Ezzat Date: Mon, 9 Nov 2026 09:21:20 +0200 Subject: [PATCH] Adding templates --- .gitea/workflows/checkout-code.yml | 46 +++++++++++++++++++++++ .gitea/workflows/load-env.yml | 59 ++++++++++++++++++++++++++++++ 2 files changed, 105 insertions(+) create mode 100644 .gitea/workflows/checkout-code.yml create mode 100644 .gitea/workflows/load-env.yml diff --git a/.gitea/workflows/checkout-code.yml b/.gitea/workflows/checkout-code.yml new file mode 100644 index 0000000..6696bc4 --- /dev/null +++ b/.gitea/workflows/checkout-code.yml @@ -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 \ No newline at end of file diff --git a/.gitea/workflows/load-env.yml b/.gitea/workflows/load-env.yml new file mode 100644 index 0000000..59a89e9 --- /dev/null +++ b/.gitea/workflows/load-env.yml @@ -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 \ No newline at end of file