1818 env :
1919 CI : true
2020 STAGE : production
21- SSH_ADDRESS_PRD : ${{ secrets.SSH_ADDRESS_PRD }}
2221 DEPLOY_VERSION : ${{ github.ref_type == 'tag' && github.ref_name || format('0.0.0-{0}-{1}-{2}', github.ref_name, github.run_number, github.run_attempt) }}
2322
2423 steps :
@@ -34,29 +33,103 @@ jobs:
3433 uses : actions/download-artifact@v4
3534 with :
3635 name : build output (ubuntu-latest, 20)
37- - name : " SSH"
38- uses : shimataro/ssh-key-action@v2
36+
37+ - name : " Generate Bundle info"
38+ run : npm run generate:bundle-info $DEPLOY_VERSION production
39+
40+ - name : " Sentry Release"
41+ # todo-zm: remove sentry entirely
42+ run : cd ./api && npm run generate:sentry-release $DEPLOY_VERSION production ${{ secrets.SENTRY_AUTH_TOKEN }}
43+
44+ - name : " Write ./api deps into Dockerfile..."
45+ run : |
46+ cd ./api
47+ npm run prepare-dockerfile
48+
49+ - name : Build docker image
50+ run : |
51+ docker buildx build -f api.Dockerfile . -t ghcr.io/dzcode-io/api-dot-production-dot-dzcode-dot-io-server:latest
52+ env :
53+ DOCKER_BUILDKIT : 1
54+
55+ - name : Push docker image
56+ run : |
57+ echo $CR_PAT | docker login ghcr.io -u dzcode-io --password-stdin
58+ docker push ghcr.io/dzcode-io/api-dot-production-dot-dzcode-dot-io-server:latest
59+ env :
60+ CR_PAT : ${{ secrets.CR_PAT }}
61+
62+ docker-build-push-web-server :
63+ needs : build
64+ runs-on : ubuntu-latest
65+ env :
66+ CI : true
67+ STAGE : production
68+ DEPLOY_VERSION : ${{ github.ref_type == 'tag' && github.ref_name || format('0.0.0-{0}-{1}-{2}', github.ref_name, github.run_number, github.run_attempt) }}
69+
70+ steps :
71+ - name : " Git"
72+ uses : actions/checkout@v4
73+ - name : " Nodejs"
74+ uses : actions/setup-node@v4
75+ with :
76+ node-version : " 20"
77+ cache : " npm"
78+ - run : npm ci
79+ - name : Download artifact
80+ uses : actions/download-artifact@v4
3981 with :
40- key : ${{ secrets.SSH_KEY }}
41- known_hosts : ${{ secrets.SSH_KNOWN_HOSTS }}
42- - name : " Bundle info"
82+ name : build output (ubuntu-latest, 20)
83+
84+ - name : " Generate Bundle info"
4385 run : npm run generate:bundle-info $DEPLOY_VERSION production
44- - name : " Bundle ./web"
45- run : npx lerna run bundle:alone --scope @dzcode.io/web
86+
4687 - name : " Sentry Release"
47- run : npm run generate:sentry-release $DEPLOY_VERSION production ${{ secrets.SENTRY_AUTH_TOKEN }}
48- - name : " Pre-deploy"
49- run : npm run pre-deploy
50- - name : " Deploy"
51- run : npm run deploy
52-
53- lighthouse :
54- needs : bundle-deploy
55- uses : ./.github/workflows/ci.reusable.lighthouse.yml
56- with :
57- serverBaseUrl : " https://lh.dzcode.io"
58- testBaseUrl : " https://www.dzcode.io"
59- stage : " production"
60- secrets :
61- LH_SERVER_TOKEN_STG : ${{ secrets.LH_SERVER_TOKEN_STG }}
62- LH_SERVER_TOKEN_PRD : ${{ secrets.LH_SERVER_TOKEN_PRD }}
88+ # todo-zm: remove sentry entirely
89+ run : cd ./web && npm run generate:sentry-release $DEPLOY_VERSION production ${{ secrets.SENTRY_AUTH_TOKEN }}
90+
91+ - name : " Bundle ./web for deployment"
92+ run : |
93+ cd ./web
94+ npm run bundle:alone
95+ npm run pre-deploy
96+
97+ - name : " Write ./web-server deps into Dockerfile..."
98+ run : |
99+ cd ./web-server
100+ npm run prepare-dockerfile
101+
102+ - name : Build docker image
103+ run : |
104+ docker buildx build -f web-server.Dockerfile . -t ghcr.io/dzcode-io/production-dot-dzcode-dot-io-server:latest
105+ env :
106+ DOCKER_BUILDKIT : 1
107+
108+ - name : Push docker image
109+ run : |
110+ echo $CR_PAT | docker login ghcr.io -u dzcode-io --password-stdin
111+ docker push ghcr.io/dzcode-io/production-dot-dzcode-dot-io-server:latest
112+ env :
113+ CR_PAT : ${{ secrets.CR_PAT }}
114+
115+ deploy-to-zcluster :
116+ needs : [docker-build-push-api, docker-build-push-web-server]
117+ runs-on : ubuntu-latest
118+ env :
119+ CI : true
120+
121+ steps :
122+ - name : " Git"
123+ uses : actions/checkout@v4
124+
125+ - name : install zcluster
126+ run : |
127+ curl -fsSL https://infra.zak-man.com/install.sh | sh
128+ echo "/home/runner/.zcluster/bin" >> $GITHUB_PATH
129+
130+ - name : Deploy to zcluster
131+ run : zcluster deploy -p production-dzcode ./docker-compose.production.yml
132+ env :
133+ ADMIN_AUTH_TOKEN : ${{ secrets.ADMIN_AUTH_TOKEN }}
134+ OPENAI_KEY : ${{ secrets.OPENAI_KEY }}
135+ GITHUB_TOKEN : ${{ secrets.API_GITHUB_TOKEN }}
0 commit comments