清炖牛肋条 黄豆炖猪蹄 #17
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Trigger Verifier on Commit | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
send-post-request: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Python and Install pyotp | |
run: | | |
python3 -m venv venv | |
source venv/bin/activate | |
pip install pyotp | |
- name: Generate TOTP Code | |
id: generate_totp | |
run: | | |
echo "SECRET_KEY=${{ secrets.SECRET_KEY }}" >> $GITHUB_ENV | |
echo "import pyotp; print(pyotp.TOTP('${{ secrets.SECRET_KEY }}').now())" > totp.py | |
TOTP_CODE=$(venv/bin/python3 totp.py) | |
echo "code=$TOTP_CODE" >> $GITHUB_ENV | |
- name: Send deployment request to AuthRun | |
id: send_post | |
run: | | |
response=$(curl -X POST "${{ secrets.FLASK_VERIFIER_URL }}/verify" \ | |
-d "code=${{ env.code }}" -s) | |
echo "Response: $response" | |
echo "$response" > response.json | |
success=$(echo $response | jq -r '.success') | |
message=$(echo $response | jq -r '.message') | |
if [[ "$success" == "false" ]]; then | |
echo "Message: $message" | |
echo "Try manual deployment" | |
exit 1 | |
else | |
echo "Verification succeeded." | |
fi | |
env: | |
code: ${{ env.code }} | |
FLASK_VERIFIER_URL: ${{ secrets.FLASK_VERIFIER_URL }} | |
- name: Handle Success | |
if: steps.send_post.outputs.success == 'true' | |
run: echo "Action completed successfully!" |