Files
ansible-gitea/.gitea/workflows/main.yml
T
2025-12-08 17:50:09 +07:00

39 lines
2.5 KiB
YAML

# This is the main CI/CD workflow for the cms-api application.
# It triggers on pushes of tags matching semantic versioning with environment suffixes.
name: CI/CD for project
on:
push:
tags:
- 'v*' # Matches v-prefixed tags like v1.0.0, v1.0.0-dev.1, v1.0.0-stg.1
jobs:
# This job calls the reusable deployment workflow.
deploy_service:
# Set the environment name based on the Git tag. Default is 'development'.
environment: ${{ (contains(github.ref_name, '-stg.')) && 'staging' || (contains(github.ref_name, '-prod.')) && 'production' || 'development' }}
uses: devops/ansible-gitea/.gitea/workflows/deploy.yml@main
# Provide the specific inputs for this application.
with:
app_name: ${{ github.event.repository.name }}
# Set deploy_env based on the Git tag. Default is 'development'.
deploy_env: ${{ (contains(github.ref_name, '-stg.')) && 'staging' || (contains(github.ref_name, '-prod.')) && 'production' || 'development' }}
env_type: ${{ (contains(github.ref_name, 'worker')) && 'worker' || '' }}
# Pass the required secrets to the reusable workflow.
# These secrets must be configured in the Gitea settings for this repository
# with suffixes _DEV, _STG, _PROD. The workflow defaults to _DEV secrets.
secrets:
SERVER_HOST: ${{ (contains(github.ref_name, '-stg.')) && vars.SERVER_HOST_STG || (contains(github.ref_name, '-prod.')) && vars.SERVER_HOST_PROD || vars.SERVER_HOST_DEV || 'localhost' }}
SERVER_PORT: ${{ (contains(github.ref_name, '-stg.')) && vars.SERVER_PORT_STG || (contains(github.ref_name, '-prod.')) && vars.SERVER_PORT_PROD || vars.SERVER_PORT_DEV || '22' }}
SERVER_USER: ${{ (contains(github.ref_name, '-stg.')) && vars.SERVER_USER_STG || (contains(github.ref_name, '-prod.')) && vars.SERVER_USER_PROD || vars.SERVER_USER_DEV || 'cicd' }}
SERVER_SSH_PRIVATE_KEY: ${{ (contains(github.ref_name, '-stg.')) && secrets.SERVER_SSH_PRIVATE_KEY_STG || (contains(github.ref_name, '-prod.')) && secrets.SERVER_SSH_PRIVATE_KEY_PROD || secrets.SERVER_SSH_PRIVATE_KEY_DEV || '' }}
SERVER_PASSWORD: ${{ (contains(github.ref_name, '-stg.')) && secrets.SERVER_PASSWORD_STG || (contains(github.ref_name, '-prod.')) && secrets.SERVER_PASSWORD_PROD || secrets.SERVER_PASSWORD_DEV || '' }}
VAULT_PASSWORD: ${{ secrets.VAULT_PASSWORD }}
VAULT_ROLE: ${{ vars.VAULT_ROLE }}
VAULT_ADDR: ${{ vars.VAULT_ADDR || 'https://vault.nguoiduathu.eu.org' }}
DOCKER_REGISTRY: ${{ vars.DOCKER_REGISTRY || github.server_url }}