Skip to content

Commit

Permalink
handle creation of a deployment
Browse files Browse the repository at this point in the history
Signed-off-by: Denis Baryshev <[email protected]>
  • Loading branch information
dennybaa committed Feb 22, 2022
1 parent 062c2a1 commit 99b8c08
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 36 deletions.
95 changes: 60 additions & 35 deletions .github/workflows/deploy.stage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,47 +9,72 @@ on:
tags:
- hotfix-*

# Disable simultaneous deployments into stage
concurrency: deploy-stage

jobs:
images:
name: Build Docker Images
runs-on: [self-hosted, MAIN]

outputs:
image-tag: ${{ steps.sha.outputs.short }}

steps:
- uses: actions/checkout@v2
- id: sha
run: echo "::set-output name=short::$(git rev-parse --short HEAD)"
# - name: setup-env
# run: |
# echo ZKSYNC_HOME=$(pwd) >> $GITHUB_ENV
# echo CI=1 >> $GITHUB_ENV
# echo $(pwd)/bin >> $GITHUB_PATH
-
name: setup-env
run: |
echo ZKSYNC_HOME=$(pwd) >> $GITHUB_ENV
echo CI=1 >> $GITHUB_ENV
echo $(pwd)/bin >> $GITHUB_PATH
-
name: init
run: |
cargo sqlx --version || cargo install sqlx-cli
zk
zk run yarn
cp etc/tokens/{test,localhost}.json
zk run verify-keys unpack
zk up
zk db basic-setup
-
name: update-images
run: |
docker login -u ${{ secrets.DOCKER_USER }} -p ${{ secrets.DOCKER_PASSWORD }}
echo zk docker push rust
-
name: docker-down
if: always()
run: |
docker-compose down
# - name: init
# run: |
# cargo sqlx --version || cargo install sqlx-cli
# zk
# zk run yarn
# cp etc/tokens/{test,localhost}.json
# zk run verify-keys unpack
# zk up
# zk db basic-setup
setup:
name: Setup
uses: matter-labs/zksync-dev/.github/workflows/setup.runtime.yml@devops/refactor-workflow-call
needs: [images]
with:
environment: stage
create-deployment: true

# - name: update-images
# run: |
# docker login -u ${{ secrets.DOCKER_USER }} -p ${{ secrets.DOCKER_PASSWORD }}
# zk docker push rust
update:
name: Update
uses: matter-labs/zksync-dev/.github/workflows/server.update-config.yml@devops/refactor-workflow-call
needs: [setup]
with:
ref: master
cluster: ${{ needs.setup.outputs.cluster }}
environment: ${{ needs.setup.outputs.environment }}
namespace: ${{ needs.setup.outputs.release-namespace }}
secrets:
github-token: ${{ secrets.GH_TOKEN }}

# - name: docker-down
# if: always()
# run: |
# docker-compose down
test:
name: Result
runs-on: [self-hosted, stage]
needs: [images]
steps:
- run: |
echo ${{ needs.images.outputs.image-tag }}
deploy:
name: Deploy
uses: matter-labs/zksync-dev/.github/workflows/deploy.yml@devops/refactor-workflow-call
needs: [setup, update]
with:
cluster: ${{ needs.setup.outputs.cluster }}
environment: ${{ needs.setup.outputs.environment }}
release-environment: ${{ needs.setup.outputs.release-environment }}
release-namespace: ${{ needs.setup.outputs.release-namespace }}
deployment-id: ${{ needs.setup.outputs.deployment-id }}
image-tag: ${{ needs.setup.outputs.sha-short }}
secrets:
github-token: ${{ secrets.GH_TOKEN }}
4 changes: 4 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ on:
description: Deployment for this pipeline
type: string
required: true
config-ref:
description: Specifies config reposiotry ref to
type: string
required: false
scaleup:
description: Force scaling the server deployment up to 1 replica
type: boolean
Expand Down
29 changes: 28 additions & 1 deletion .github/workflows/setup.runtime.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,15 @@ on:
description: Zksync Environment (mainnet, stage, rinkeby etc)
type: string
required: true
create-deployment:
description: Create GitHub deployment for the given environment
type: boolean
required: false
default: false
outputs:
environment:
description: Zksync Environment
value: ${{ inputs.environment }}
release-environment:
description: Helmfile release environment
value: ${{ jobs.setup.outputs.hfEnv }}
Expand All @@ -16,6 +24,12 @@ on:
cluster:
description: Runtime cluster label, i.e. self-hosted runner label (mainnet, testnet or stage)
value: ${{ jobs.setup.outputs.cluster }}
sha-short:
description: Short SHA used for image tagging
value: ${{ jobs.setup.outputs.sha-short }}
deployment-id:
description: GitHub Deployment ID, a non-empty value when setup handles the deployment creation
value: ${{ jobs.setup.outputs.deployment-id }}

defaults:
run:
Expand All @@ -27,11 +41,13 @@ concurrency: setup-env-${{ inputs.environment }}
jobs:
setup:
name: Runtime
runs-on: [k8s, stage]
runs-on: [self-hosted, stage]
outputs:
hfEnv: ${{ steps.envMap.outputs.hfEnv }}
namespace: ${{ steps.envMap.outputs.namespace }}
cluster: ${{ steps.envMap.outputs.cluster }}
sha-short: ${{ steps.sha.outputs.short }}
deployment-id: ${{ steps.deployment.outputs.deployment_id }}

steps:
- uses: actions/checkout@v2
Expand All @@ -54,3 +70,14 @@ jobs:
"^ropsten$": { "cluster": "testnet" },
"^mainnet$": { "cluster": "mainnet", "hfEnv": "prod", "namespace": "zksync" }
}
-
run: echo "::set-output name=short::$(git rev-parse --short HEAD)"
id: sha
-
name: Create GitHub Deployment
uses: chrnorm/deployment-action@releases/v1
id: deployment
if: inputs.create-deployment
with:
token: ${{ github.token }}
environment: ${{ inputs.environment }}

0 comments on commit 99b8c08

Please sign in to comment.