Files
andersonid 0e770777d5 Fix S2I workflow to stop automatic failures
- Disable automatic trigger on push to main
- Change to manual-only workflow dispatch
- Add webhook token validation
- Prevent emails from failed automatic builds
- Add clear instructions for webhook setup
2025-10-04 11:48:00 -03:00

86 lines
3.2 KiB
YAML
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
name: S2I Deploy (Manual Only)
on:
workflow_dispatch:
inputs:
openshift_server:
description: 'OpenShift Server URL'
required: true
default: 'https://oru.apps.shrocp4upi419ovn.lab.upshift.rdu2.redhat.com'
namespace:
description: 'Target Namespace'
required: true
default: 'resource-governance'
env:
APP_NAME: resource-governance
NAMESPACE: resource-governance
jobs:
s2i-deploy:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Trigger S2I Build via Webhook
run: |
echo "🚀 Triggering S2I build via Generic Webhook..."
echo "📦 Repository: ${{ github.repository }}"
echo "🔗 Commit: ${{ github.sha }}"
echo "🌿 Branch: ${{ github.ref_name }}"
# URL do webhook genérico do OpenShift (usar API server, não rota da aplicação)
# NOTA: Este webhook precisa ser configurado no cluster OpenShift de destino
WEBHOOK_URL="${{ inputs.openshift_server }}/apis/build.openshift.io/v1/namespaces/${{ inputs.namespace || env.NAMESPACE }}/buildconfigs/${{ env.APP_NAME }}/webhooks/PLACEHOLDER_WEBHOOK_TOKEN/generic"
echo "🔗 Webhook URL: $WEBHOOK_URL"
# Verificar se o webhook token não é placeholder
if [[ "$WEBHOOK_URL" == *"PLACEHOLDER_WEBHOOK_TOKEN"* ]]; then
echo "❌ ERRO: Webhook token não configurado!"
echo " Para usar este workflow:"
echo "1. Configure o webhook no OpenShift cluster"
echo "2. Substitua PLACEHOLDER_WEBHOOK_TOKEN pelo token real"
echo "3. Execute o workflow novamente"
exit 1
fi
# Disparar build S2I
curl -X POST "$WEBHOOK_URL" \
-H "Content-Type: application/json" \
-d '{
"repository": {
"full_name": "${{ github.repository }}",
"clone_url": "${{ github.server_url }}/${{ github.repository }}.git"
},
"ref": "${{ github.ref }}",
"head_commit": {
"id": "${{ github.sha }}",
"message": "${{ github.event.head_commit.message }}",
"author": {
"name": "${{ github.event.head_commit.author.name }}",
"email": "${{ github.event.head_commit.author.email }}"
}
},
"pusher": {
"name": "${{ github.actor }}"
}
}' \
--fail-with-body
echo "✅ S2I build triggered successfully!"
- name: Wait for build completion (optional)
if: github.event_name == 'workflow_dispatch'
run: |
echo "⏳ Waiting for S2I build to complete..."
echo " Check OpenShift console for build progress:"
echo " oc get builds -n ${{ inputs.namespace || env.NAMESPACE }}"
echo " oc logs -f buildconfig/${{ env.APP_NAME }} -n ${{ inputs.namespace || env.NAMESPACE }}"
echo ""
echo "🎯 Build will complete automatically in the background"
echo "📱 You can monitor progress in the OpenShift console"