@@ -158,7 +158,7 @@ jobs:
158158 id : metaProd
159159 uses : docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
160160 with :
161- images : saneasp /back-sanea-prod
161+ images : ${{ secrets.DOCKER_USERNAME }} /back-sanea-prod
162162 tags : |
163163 type=raw,value=${{ steps.version.outputs.new_version }}
164164 type=raw,value=latest
@@ -181,7 +181,7 @@ jobs:
181181 id : metaDev
182182 uses : docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
183183 with :
184- images : saneasp/front- back-dev
184+ images : ${{ secrets.DOCKER_USERNAME }}/ back-sanea -dev
185185 tags : |
186186 type=raw,value=${{ steps.version.outputs.new_version }}
187187 type=raw,value=latest
@@ -197,6 +197,52 @@ jobs:
197197 labels : ${{ steps.metaDev.outputs.labels }}
198198 env :
199199 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
200+ # --- Deploy automático via Render ---
201+ - name : Deploy via Render API
202+ env :
203+ RENDER_API_KEY : ${{secrets.RENDER_API_KEY}}
204+ SERVICE_ID : ${{secrets.SERVICE_ID}}
205+ REPO_NAME : ${{secrets.REPO_NAME_PROD}}
206+ run : |
207+ echo "Criando payload para deploy da versão latest"
208+
209+ PAYLOAD=$(jq -n \
210+ --arg image "docker.io/${{ secrets.DOCKER_USERNAME }}/$REPO_NAME:latest" \
211+ --arg version "latest" \
212+ '{
213+ clearCache: "clear",
214+ imageUrl: $image,
215+ overrideImage: true,
216+ imagePullPolicy: "Always"
217+ }'
218+ )
219+
220+ echo "Payload JSON gerado:"
221+ echo "$PAYLOAD" | jq .
222+
223+ echo "Iniciando deploy no Render..."
224+
225+ RESPONSE=$(curl -i -s -X POST \
226+ "https://api.render.com/v1/services/$SERVICE_ID/deploys" \
227+ -H "Accept: application/json" \
228+ -H "Content-Type: application/json" \
229+ -H "Authorization: Bearer $RENDER_API_KEY" \
230+ -d "$PAYLOAD"
231+ )
232+
233+ echo "Resposta completa:"
234+ echo "$RESPONSE"
235+
236+ HTTP_STATUS=$(echo "$RESPONSE" | grep HTTP | awk '{print $2}')
237+
238+ echo "Status da resposta HTTP: $HTTP_STATUS"
239+
240+ if [[ "$HTTP_STATUS" =~ ^2[0-9]{2}$ ]]; then
241+ echo "Deploy iniciado com sucesso!"
242+ else
243+ echo "Falha no deploy!"
244+ exit 1
245+ fi
200246
201247 # --- Enviar e-mail em caso de falha ---
202248 notify_failure :
0 commit comments