-
Notifications
You must be signed in to change notification settings - Fork 0
78 lines (68 loc) · 2.26 KB
/
deploy.yml
File metadata and controls
78 lines (68 loc) · 2.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
name: Deploy API
on:
workflow_dispatch:
workflow_run:
workflows: ["Check"]
branches: [main]
types: [completed]
concurrency:
group: deploy-production
cancel-in-progress: true
permissions:
contents: read
jobs:
deploy:
name: Deploy
if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
timeout-minutes: 30
environment: production
steps:
- name: Resolve deploy ref
id: ref
shell: bash
run: |
if [[ "${{ github.event_name }}" == "workflow_run" ]]; then
echo "ref=${{ github.event.workflow_run.head_sha }}" >> "$GITHUB_OUTPUT"
else
echo "ref=${GITHUB_SHA}" >> "$GITHUB_OUTPUT"
fi
- uses: actions/checkout@v6
with:
ref: ${{ steps.ref.outputs.ref }}
- name: Validate required secrets
shell: bash
env:
PROD_VPS_PASSWORD: ${{ secrets.PROD_VPS_PASSWORD }}
PROD_QWEN_OAUTH_CREDS: ${{ secrets.PROD_QWEN_OAUTH_CREDS }}
PROD_TELEGRAM_BOT_TOKEN: ${{ secrets.PROD_TELEGRAM_BOT_TOKEN }}
run: |
missing=()
for name in \
PROD_VPS_PASSWORD \
PROD_QWEN_OAUTH_CREDS \
PROD_TELEGRAM_BOT_TOKEN
do
if [[ -z "${!name}" ]]; then
missing+=("$name")
fi
done
if [[ ${#missing[@]} -gt 0 ]]; then
printf 'Missing required secrets: %s\n' "${missing[*]}" >&2
exit 1
fi
- name: Install sshpass
run: sudo apt-get update && sudo apt-get install -y sshpass
- name: Validate deploy script
run: bash -n scripts/deploy-prod.sh
- name: Deploy production stack
env:
PROD_VPS_PASSWORD: ${{ secrets.PROD_VPS_PASSWORD }}
PROD_QWEN_OAUTH_CREDS: ${{ secrets.PROD_QWEN_OAUTH_CREDS }}
PROD_TELEGRAM_BOT_TOKEN: ${{ secrets.PROD_TELEGRAM_BOT_TOKEN }}
run: |
# deploy-prod.sh: arg1=SSH password, arg2=Telegram bot token only.
# Qwen OAuth is read from env PROD_QWEN_OAUTH_CREDS (not a CLI arg).
bash ./scripts/deploy-prod.sh \
"$PROD_VPS_PASSWORD" \
"$PROD_TELEGRAM_BOT_TOKEN"