Files
hla_framework_bd/.gitea/workflows/add-new-service.yml
T

74 lines
2.4 KiB
YAML

name: Add new service
on:
push:
branches:
- 'feature/add-service-*'
# TODO: when to deploy to prod? Manual (i.e. cli command)?
jobs:
deploy:
runs-on: hla-dev
env:
ANSIBLE_CONFIG: "${{ github.workspace }}/ansible/ansible.cfg"
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install and setup uv
uses: actions/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
with:
version: "latest"
enable-cache: true # Speeds up runs by caching python dependencies # TODO: does this work?
- name: Install Python 3.10
run: uv python install 3.10
- name: Run tests
run: |
cd scripts && uv run pytest
- name: Parse Service Directory Name
id: parse_branch
# Uses bash shell parameter elimination to strip 'feature/add-service-' from the front
run: |
BRANCH="${{ github.ref_name }}"
SERVICE_NAME="${BRANCH#feature/add-service-}"
echo "service_name_lower=$SERVICE_NAME" >> $GITHUB_OUTPUT
# TODO: look into venv caching (will do later in case we move from uv to pixi)
# - name: Cache Python Virtual Environment
# uses: actions/cache@v4
# with:
# path: .venv
# # Changes uv.lock will automatically invalidate the cache and rebuild
# key: ${{ runner.os }}-uv-cli-venv-${{ hashFiles('cli/uv.lock') }}
# restore-keys: |
# ${{ runner.os }}-uv-cli-venv-
# # Only create the venv if the cache didn't restore an existing one
# if [ ! -d ".venv" ]; then
# echo "Building new .venv"
# uv venv .venv
# fi
- name: Initialize Virtual Environment from cli/uv.lock
run: |
uv venv .venv
uv sync --directory cli
- name: Install Ansible Galaxy Collections
run: |
uv run ansible-galaxy collection install -r ansible/collections/requirements.yml -p ./ansible/installed-collections
# TODO: dev/prod
- name: Run New Service Playbook
working-directory: ansible
run: |
uv run ansible-playbook playbooks/add-new-service.yml \
-i "inventories/dev/hosts.yml" \
--extra-vars="repo_root=${{ github.workspace }}" \
--extra-vars="service_name_lower=${{ steps.parse_branch.outputs.service_name_lower }}" \
-v