diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0c75b4c..a59250a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,32 +1,25 @@ on: - workflow_dispatch: push: branches: - main -env: - DEPLOY_TOKEN: jrI6OqLIx8JVLbPLs7rGIJOojQ9FpRcxoh8GobHv-Zh_M-rKFhECaQDKRMTZAkwccO6PhuE7TUYrnKWG - jobs: - deployment: + deploy: runs-on: ubuntu-latest steps: - name: Send Deploy Request id: deploy uses: fjogeleit/http-request-action@v1 with: - url: 'https://alitayyeb.ir/deploy-from-git/' - method: 'POST' - customHeaders: '{"Authorization": "${{ DEPLOY_TOKEN }}"}' - - name: Print Deploy Response + url: 'https://alitayyeb.ir/deploy-from-git' + method: 'GET' + timeout: 20000 + customHeaders: '{"Authorization": "${{ secrets.DEPLOY_KEY }}"}' + - name: Log Deploy Response run: | - echo ${{ fromJson(steps.deploy.outputs.response).detail }} - echo ${{ fromJson(steps.deploy.outputs.response).stdout }} - echo ${{ fromJson(steps.deploy.outputs.response).stderr }} - - name: The job has failed - if: ${{ failure() || fromJSON(steps.deploy.outputs.response.success)}} - - name: The job has succeeded - if: ${{ success() }} - - - + echo "detail: ${{ fromJson(steps.deploy.outputs.response).detail }}" + echo "stdout: ${{ fromJson(steps.deploy.outputs.response).stdout }}" + echo "stderr: ${{ fromJson(steps.deploy.outputs.response).stderr }}" + - name: Check deploy failure + if: ${{ failure() || !fromJSON(steps.deploy.outputs.response).success}} + run: exit 1 diff --git a/main.py b/main.py index 7598848..de25a54 100644 --- a/main.py +++ b/main.py @@ -20,7 +20,7 @@ def verify_token(req: Request): @app.get("/deploy-from-git") async def deploy(config: dict = Depends(verify_token)): result = subprocess.run(config['shell_command'], shell=True, capture_output=True) - success, detail = (True, 'Deployed successfully.') if not result.stderr else (False, 'Deploy failed.') + success, detail = (True, 'Deployed successfully.') if result.returncode == 0 else (False, 'Deploy failed.') return { 'success': success, 'detail': detail,