Skip to content

Commit 7a55d02

Browse files
committed
add auto dpeloy on main merge
1 parent 4299961 commit 7a55d02

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

.github/workflows/build-and-test.yml

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,30 @@ jobs:
4141
secrets:
4242
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
4343
EZLOCALAI_URI: ${{ secrets.EZLOCALAI_URI }}
44-
EZLOCALAI_API_KEY: ${{ secrets.EZLOCALAI_API_KEY }}
44+
EZLOCALAI_API_KEY: ${{ secrets.EZLOCALAI_API_KEY }}
45+
deploy:
46+
runs-on: ubuntu-22.04
47+
name: Deploy to dev server
48+
needs: build
49+
if: github.ref == 'refs/heads/main'
50+
steps:
51+
- name: Deploy Application
52+
id: deploy
53+
run: |
54+
RESPONSE=$(curl -s -w "\nHTTP_STATUS_CODE:%{http_code}" -X POST "${{ secrets.DEPLOY_URI }}" \
55+
-H "Content-Type: application/json" \
56+
-H "X-API-Key: ${{ secrets.DEPLOY_SECRET }}" \
57+
-d '{"domain": "${{ secrets.DEPLOY_DOMAIN }}"}')
58+
59+
HTTP_STATUS=$(echo "$RESPONSE" | grep -o "HTTP_STATUS_CODE:[0-9]*" | cut -d: -f2)
60+
RESPONSE_BODY=$(echo "$RESPONSE" | sed '/HTTP_STATUS_CODE:/d')
61+
62+
echo "deploy_response=$RESPONSE_BODY" >> $GITHUB_OUTPUT
63+
echo "deploy_status=$HTTP_STATUS" >> $GITHUB_OUTPUT
64+
65+
if [ "$HTTP_STATUS" -ge 200 ] && [ "$HTTP_STATUS" -lt 300 ]; then
66+
echo "Deployment successful with status $HTTP_STATUS"
67+
else
68+
echo "Deployment failed with status $HTTP_STATUS"
69+
exit 1
70+
fi

0 commit comments

Comments
 (0)