feat: trigger CD pipeline after image push
Some checks failed
CI Pipeline / lint (push) Successful in 17s
CI Pipeline / build (push) Successful in 40s
CI Pipeline / test (push) Successful in 1m5s
CI Pipeline / security-scan (push) Successful in 1m22s
CI Pipeline / autotag (push) Successful in 17s
CI Pipeline / push (push) Successful in 19s
CI Pipeline / update-cd (push) Failing after 16s

Add stage 7 to trigger terraform-docker-openldap pipeline via Gitea API
after successfully pushing a new image to the registry. This enables
automatic deployment of new container versions.

Requires GITEA_TOKEN secret and GITEA_URL variable to be configured.
This commit is contained in:
Patrick de Ruiter 2025-12-28 01:12:13 +01:00
parent d5405f3bba
commit 9b15cc31cb
Signed by: pderuiter
GPG Key ID: 5EBA7F21CF583321

View File

@ -273,23 +273,36 @@ jobs:
if: always() if: always()
run: docker logout ${{ env.REGISTRY }} || true run: docker logout ${{ env.REGISTRY }} || true
# Stage 7: Update CD pipeline (trigger deployment) # Stage 7: Trigger CD pipeline for terraform-docker-openldap
update-cd: update-cd:
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: push needs: push
if: needs.push.result == 'success' if: needs.push.result == 'success'
steps: steps:
- name: Trigger CD pipeline - name: Trigger terraform-docker-openldap pipeline
run: | run: |
echo "==============================================" echo "=============================================="
echo " Ready to update CD pipeline" echo " Triggering CD pipeline"
echo "==============================================" echo "=============================================="
echo "New version: ${{ needs.push.outputs.version }}" echo "New version: ${{ needs.push.outputs.version }}"
echo "Full image: ${{ needs.push.outputs.full_image }}" echo "Full image: ${{ needs.push.outputs.full_image }}"
echo "" echo ""
echo "TODO: Add step to update version in CD repository"
echo "This could be:" # Trigger the Gitea Actions workflow via repository dispatch
echo " - Update docker-compose.yml in infra repo" curl -X POST \
echo " - Update Helm values" -H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \
echo " - Trigger ArgoCD sync" -H "Content-Type: application/json" \
"${{ vars.GITEA_URL }}/api/v1/repos/wbyc/terraform-docker-openldap/actions/workflows/pipeline.yaml/dispatches" \
-d '{
"ref": "main",
"inputs": {
"image_tag": "${{ needs.push.outputs.version }}"
}
}' || {
echo "::warning::Failed to trigger CD pipeline"
exit 1
}
echo "=============================================="
echo " CD pipeline triggered successfully"
echo "==============================================" echo "=============================================="