feat: launch PK testing application
Verify mini program and deploy preview / verify-deploy (push) Failing after 32s
Verify mini program and deploy preview / verify-deploy (push) Failing after 32s
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
name: Verify mini program and deploy preview
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
pull_request:
|
||||
concurrency:
|
||||
group: rice-pk-xhs-production
|
||||
cancel-in-progress: false
|
||||
jobs:
|
||||
verify-deploy:
|
||||
runs-on: ubuntu-latest
|
||||
container: { image: docker:27-cli }
|
||||
timeout-minutes: 20
|
||||
env:
|
||||
SOURCE_SERVER: ${{ gitea.server_url }}
|
||||
SOURCE_REPOSITORY: ${{ gitea.repository }}
|
||||
SOURCE_REVISION: ${{ gitea.sha }}
|
||||
DEPLOY_PORT: ${{ vars.DEPLOY_PORT || '3002' }}
|
||||
API_BASE_URL: ${{ vars.API_BASE_URL || 'http://47.76.92.159:18082' }}
|
||||
steps:
|
||||
- name: Fetch exact revision
|
||||
env: { SOURCE_TOKEN: "${{ secrets.GITEA_TOKEN }}" }
|
||||
run: |
|
||||
set -eu
|
||||
apk add --no-cache python3 nodejs curl
|
||||
python3 - <<'PY'
|
||||
import io,os,shutil,tarfile,tempfile,urllib.request
|
||||
from pathlib import Path
|
||||
url=f"{os.environ['SOURCE_SERVER'].rstrip('/')}/api/v1/repos/{os.environ['SOURCE_REPOSITORY']}/archive/{os.environ['SOURCE_REVISION']}.tar.gz"
|
||||
req=urllib.request.Request(url,headers={'Authorization':'token '+os.environ['SOURCE_TOKEN']})
|
||||
with urllib.request.urlopen(req,timeout=60) as r:data=r.read()
|
||||
with tempfile.TemporaryDirectory() as d:
|
||||
with tarfile.open(fileobj=io.BytesIO(data),mode='r:gz') as a:a.extractall(d,filter='data')
|
||||
roots=list(Path(d).iterdir());shutil.copytree(roots[0],Path.cwd(),dirs_exist_ok=True)
|
||||
PY
|
||||
- name: Check source and preview
|
||||
run: npm run check
|
||||
- name: Build preview image
|
||||
run: docker build -t "rice-pk-xhs:$SOURCE_REVISION" .
|
||||
- name: Update permanent preview container
|
||||
if: gitea.event_name == 'push' && gitea.ref == 'refs/heads/main'
|
||||
run: |
|
||||
set -eu
|
||||
docker rm -f rice-pk-xhs-preview 2>/dev/null || true
|
||||
docker run -d --name rice-pk-xhs-preview --restart unless-stopped --read-only --tmpfs /var/cache/nginx --tmpfs /var/run -e API_BASE_URL="$API_BASE_URL" -p "$DEPLOY_PORT:8080" "rice-pk-xhs:$SOURCE_REVISION"
|
||||
for i in 1 2 3 4 5 6; do curl -fsS "http://127.0.0.1:$DEPLOY_PORT/health" && exit 0; sleep 2; done
|
||||
docker logs rice-pk-xhs-preview
|
||||
exit 1
|
||||
|
||||
Reference in New Issue
Block a user