Skip to content

CI/CD - Deploy

CI/CD - Deploy #100

Workflow file for this run

name: CI/CD - Deploy
on:
workflow_run:
workflows: ["Tests"]
types: [completed]
branches: [develop]
workflow_dispatch:
jobs:
trigger-deployment:
runs-on: ubuntu-latest
if: >
github.event_name == 'workflow_dispatch' ||
(github.event.workflow_run.conclusion == 'success' &&
github.event.workflow_run.head_branch == 'develop')
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
ref: develop
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Configure Git
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
- name: Bump version
id: bump
run: |
python -c "
import json
from pathlib import Path
import os
manifest_path = Path('manifest.json')
with open(manifest_path, 'r') as f:
data = json.load(f)
version = data['version']
major, minor, patch = map(int, version.split('.'))
patch += 1
new_version = f'{major}.{minor}.{patch}'
data['version'] = new_version
with open(manifest_path, 'w') as f:
json.dump(data, f, indent=2)
f.write('\n')
print(f'Version bumped: {version} -> {new_version}')
# Export to GITHUB_OUTPUT for use in next steps
with open(os.environ['GITHUB_OUTPUT'], 'a') as f:
f.write(f'version={new_version}\n')
"
echo "Version bumped successfully"
- name: Commit and push version bump
run: |
git add manifest.json
git commit -m "🔖 Bump version [skip ci]" || echo "No changes to commit"
git push origin develop || echo "Nothing to push"
- name: Trigger n8n deployment workflow
env:
N8N_WEBHOOK_URL: ${{ secrets.N8N_WEBHOOK_URL }}
COMMIT_SHA: ${{ github.event.workflow_run.head_sha || github.sha }}
HEAD_BRANCH: ${{ github.event.workflow_run.head_branch || github.ref_name }}
run: |
echo "✅ Tests passed! Ready for deployment."
echo "📦 Version: ${{ steps.bump.outputs.version }}"
# Send webhook to n8n with deployment info
if [ -n "$N8N_WEBHOOK_URL" ]; then
# Use jq to properly escape JSON values
PAYLOAD=$(jq -n \
--arg version "${{ steps.bump.outputs.version }}" \
--arg branch "$HEAD_BRANCH" \
--arg commit_sha "$COMMIT_SHA" \
--arg repository "${{ github.repository }}" \
--arg workflow "${{ github.workflow }}" \
--arg run_id "${{ github.run_id }}" \
--arg run_number "${{ github.run_number }}" \
--arg timestamp "$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
'{
version: $version,
branch: $branch,
commit_sha: $commit_sha,
repository: $repository,
workflow: $workflow,
run_id: $run_id,
run_number: $run_number,
timestamp: $timestamp
}')
curl -X POST "$N8N_WEBHOOK_URL" \
-H "Content-Type: application/json" \
-d "$PAYLOAD"
echo "Webhook sent to n8n"
else
echo "N8N_WEBHOOK_URL not configured - skipping webhook"
fi