@@ -13,15 +13,13 @@ jobs:
1313 node-version : " 20"
1414 os : " ubuntu-latest"
1515
16- bundle- deploy :
16+ deploy-api :
1717 needs : build
1818 runs-on : ubuntu-latest
1919 env :
2020 CI : true
2121 STAGE : staging
2222 SSH_ADDRESS_STG : ${{ secrets.SSH_ADDRESS_STG }}
23- CLOUDFLARE_ACCOUNT_ID : ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
24- CLOUDFLARE_API_TOKEN : ${{ secrets.CLOUDFLARE_API_TOKEN }}
2523 DEPLOY_VERSION : ${{ github.ref_type == 'tag' && github.ref_name || format('stg-0.0.0-{0}-{1}-{2}', github.ref_name, github.run_number, github.run_attempt) }}
2624
2725 steps :
@@ -42,24 +40,73 @@ jobs:
4240 with :
4341 key : ${{ secrets.SSH_KEY }}
4442 known_hosts : ${{ secrets.SSH_KNOWN_HOSTS }}
45- - name : " Bundle info"
43+ - name : " Generate Bundle info"
4644 run : npm run generate:bundle-info $DEPLOY_VERSION stage
47- - name : " Bundle ./web"
48- run : npx lerna run bundle:alone --scope @dzcode.io/web
4945 - name : " Sentry Release"
50- run : npm run generate:sentry-release $DEPLOY_VERSION stage ${{ secrets.SENTRY_AUTH_TOKEN }}
51- - name : " Pre-deploy"
52- run : npm run pre-deploy
46+ # todo-zm: remove sentry entirely
47+ run : cd ./api && npm run generate:sentry-release $DEPLOY_VERSION stage ${{ secrets.SENTRY_AUTH_TOKEN }}
5348 - name : " Deploy"
54- run : npm run deploy:stg
49+ run : cd ./api && npm run deploy:stg
5550
56- lighthouse :
57- needs : bundle-deploy
58- uses : ./.github/workflows/ci.reusable.lighthouse.yml
59- with :
60- serverBaseUrl : " https://lh-stage.dzcode.io"
61- testBaseUrl : " https://stage.dzcode.io"
62- stage : " staging"
63- secrets :
64- LH_SERVER_TOKEN_STG : ${{ secrets.LH_SERVER_TOKEN_STG }}
65- LH_SERVER_TOKEN_PRD : ${{ secrets.LH_SERVER_TOKEN_PRD }}
51+ deploy-web-server :
52+ needs : build
53+ runs-on : ubuntu-latest
54+ env :
55+ CI : true
56+ STAGE : staging
57+ DEPLOY_VERSION : ${{ github.ref_type == 'tag' && github.ref_name || format('stg-0.0.0-{0}-{1}-{2}', github.ref_name, github.run_number, github.run_attempt) }}
58+
59+ steps :
60+ - name : " Git"
61+ uses : actions/checkout@v4
62+ - name : " Nodejs"
63+ uses : actions/setup-node@v4
64+ with :
65+ node-version : " 20"
66+ cache : " npm"
67+ - run : npm ci
68+ - name : Download artifact
69+ uses : actions/download-artifact@v4
70+ with :
71+ name : build output (ubuntu-latest, 20)
72+
73+ - name : " Generate Bundle info"
74+ run : npm run generate:bundle-info $DEPLOY_VERSION stage
75+
76+ - name : " Sentry Release"
77+ # todo-zm: remove sentry entirely
78+ run : cd ./web && npm run generate:sentry-release $DEPLOY_VERSION stage ${{ secrets.SENTRY_AUTH_TOKEN }}
79+
80+ - name : " Bundle ./web for deployment"
81+ run : |
82+ cd ./web
83+ npm run bundle
84+ npm run pre-deploy
85+
86+ - name : " Write ./web-server deps into Dockerfile..."
87+ run : |
88+ cd ./web-server
89+ npm run prepare-dockerfile
90+
91+ - name : Build docker image
92+ run : |
93+ docker buildx build -f web-server.Dockerfile . -t ghcr.io/dzcode-io/stage-dot-dzcode-dot-io-server:latest
94+ env :
95+ DOCKER_BUILDKIT : 1
96+
97+ - name : Push docker image
98+ run : |
99+ echo $CR_PAT | docker login ghcr.io -u dzcode-io --password-stdin
100+ docker push ghcr.io/dzcode-io/stage-dot-dzcode-dot-io-server:latest
101+ env :
102+ CR_PAT : ${{ secrets.CR_PAT }}
103+
104+ - name : install zcluster
105+ run : |
106+ curl -fsSL https://infra.zak-man.com/install.sh | sh
107+ echo "/home/runner/.zcluster/bin" >> $GITHUB_PATH
108+
109+ - name : Deploy to zcluster
110+ run : zcluster deploy -p stage-dzcode ./docker-compose.stage.yml
111+ env :
112+ ADMIN_AUTH_TOKEN : ${{ secrets.ADMIN_AUTH_TOKEN }}
0 commit comments