Deploy To Stage Environment #277
This file contains hidden or 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: Deploy To Stage Environment | |
on: | |
push: | |
tags: | |
- "stg-v*" | |
workflow_dispatch: | |
jobs: | |
build: | |
uses: ./.github/workflows/ci.reusable.build.yml | |
with: | |
node-version: "20" | |
os: "ubuntu-latest" | |
docker-build-push-api: | |
needs: build | |
runs-on: ubuntu-latest | |
env: | |
CI: true | |
STAGE: staging | |
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) }} | |
steps: | |
- name: "Git" | |
uses: actions/checkout@v4 | |
- name: "Nodejs" | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "20" | |
cache: "npm" | |
- run: npm ci | |
- name: Download artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: build output (ubuntu-latest, 20) | |
- name: "Generate Bundle info" | |
run: npm run generate:bundle-info $DEPLOY_VERSION stage | |
- name: "Sentry Release" | |
# todo-zm: remove sentry entirely | |
run: cd ./api && npm run generate:sentry-release $DEPLOY_VERSION stage ${{ secrets.SENTRY_AUTH_TOKEN }} | |
- name: "Write ./api deps into Dockerfile..." | |
run: | | |
cd ./api | |
npm run prepare-dockerfile | |
- name: Build docker image | |
run: | | |
docker buildx build -f api.Dockerfile . -t ghcr.io/dzcode-io/api-dot-stage-dot-dzcode-dot-io-server:latest | |
env: | |
DOCKER_BUILDKIT: 1 | |
- name: Push docker image | |
run: | | |
echo $CR_PAT | docker login ghcr.io -u dzcode-io --password-stdin | |
docker push ghcr.io/dzcode-io/api-dot-stage-dot-dzcode-dot-io-server:latest | |
env: | |
CR_PAT: ${{ secrets.CR_PAT }} | |
docker-build-push-web-server: | |
needs: build | |
runs-on: ubuntu-latest | |
env: | |
CI: true | |
STAGE: staging | |
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) }} | |
steps: | |
- name: "Git" | |
uses: actions/checkout@v4 | |
- name: "Nodejs" | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "20" | |
cache: "npm" | |
- run: npm ci | |
- name: Download artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: build output (ubuntu-latest, 20) | |
- name: "Generate Bundle info" | |
run: npm run generate:bundle-info $DEPLOY_VERSION stage | |
- name: "Sentry Release" | |
# todo-zm: remove sentry entirely | |
run: cd ./web && npm run generate:sentry-release $DEPLOY_VERSION stage ${{ secrets.SENTRY_AUTH_TOKEN }} | |
- name: "Bundle ./web for deployment" | |
run: | | |
cd ./web | |
npm run bundle:alone | |
npm run pre-deploy | |
- name: "Write ./web-server deps into Dockerfile..." | |
run: | | |
cd ./web-server | |
npm run prepare-dockerfile | |
- name: Build docker image | |
run: | | |
docker buildx build -f web-server.Dockerfile . -t ghcr.io/dzcode-io/stage-dot-dzcode-dot-io-server:latest | |
env: | |
DOCKER_BUILDKIT: 1 | |
- name: Push docker image | |
run: | | |
echo $CR_PAT | docker login ghcr.io -u dzcode-io --password-stdin | |
docker push ghcr.io/dzcode-io/stage-dot-dzcode-dot-io-server:latest | |
env: | |
CR_PAT: ${{ secrets.CR_PAT }} | |
deploy-to-zcluster: | |
needs: [docker-build-push-api, docker-build-push-web-server] | |
runs-on: ubuntu-latest | |
env: | |
CI: true | |
steps: | |
- name: "Git" | |
uses: actions/checkout@v4 | |
- name: install zcluster | |
run: | | |
curl -fsSL https://infra.zak-man.com/install.sh | sh | |
echo "/home/runner/.zcluster/bin" >> $GITHUB_PATH | |
- name: Deploy to zcluster | |
run: zcluster deploy -p stage-dzcode ./docker-compose.stage.yml | |
env: | |
ADMIN_AUTH_TOKEN: ${{ secrets.ADMIN_AUTH_TOKEN }} | |
OPENAI_KEY: ${{ secrets.OPENAI_KEY }} | |
GITHUB_TOKEN: ${{ secrets.API_GITHUB_TOKEN }} |