Skip to content

Commit

Permalink
moved build to template
Browse files Browse the repository at this point in the history
  • Loading branch information
killmeplz committed Feb 21, 2022
1 parent bbb5676 commit bfa250d
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 52 deletions.
77 changes: 25 additions & 52 deletions .github/workflows/deploy-stage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ on:
- dev
- breaking
- hotfix/*
- build-runner-gcp
tags:
- hotfix-*

Expand All @@ -25,56 +24,30 @@ jobs:

build-images:
name: Build and Push Docker Images
runs-on: [self-hosted, ci-runner]

steps:
- uses: actions/checkout@v2
- name: setup-env
run: |
echo ZKSYNC_HOME=$(pwd) >> $GITHUB_ENV
echo CI=1 >> $GITHUB_ENV
echo $(pwd)/bin >> $GITHUB_PATH
- name: start-services
run: |
docker-compose -f docker-compose-runner.yml down
docker-compose -f docker-compose-runner.yml up -d zk postgres
- name: init
run: |
ci_run zk
ci_run zk run yarn
ci_run cp etc/tokens/{test,localhost}.json
ci_run zk run verify-keys unpack
# ci_run zk up
ci_run zk db basic-setup
- name: update-images
run: |
ci_run docker login -u ${{ secrets.DOCKER_USER }} -p ${{ secrets.DOCKER_PASSWORD }}
ci_run zk docker push rust
- name: docker-down
if: always()
run: |
docker-compose -f docker-compose-runner.yml down
needs: [setup]
uses: ./.github/workflows/template-docker-build.yml
secrets:
DOCKERHUB_USER: ${{ secrets.DOCKERHUB_USER }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
with:
image_tag: ${{ needs.setup.outputs.image_tag }}

# Reminder: when disabling the deploy stage - comment the whole job out!
# deploy:
# name: Deploy Stage environment
# runs-on: [k8s, deployer, stage]
# needs: [setup, build-images]
# steps:
# - name: Deploy
# uses: aurelien-baudet/workflow-dispatch@v2
# with:
# workflow: Deploy
# token: ${{ secrets.GH_TOKEN }}
# wait-for-completion-timeout: 10m
# wait-for-completion-interval: 1m
# inputs: |
# {
# "environment": "stage",
# "image_tag": "${{ needs.setup.outputs.image_tag }}",
# "config_ref": "master"
# }
deploy:
name: Deploy Stage environment
runs-on: [k8s, deployer, stage]
needs: [setup, build-images]
steps:
- name: Deploy
uses: aurelien-baudet/workflow-dispatch@v2
with:
workflow: Deploy
token: ${{ secrets.GH_TOKEN }}
wait-for-completion-timeout: 10m
wait-for-completion-interval: 1m
inputs: |
{
"environment": "stage",
"image_tag": "${{ needs.setup.outputs.image_tag }}",
"config_ref": "master"
}
51 changes: 51 additions & 0 deletions .github/workflows/template-docker-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Build docker image
on:
workflow_call:
secrets:
DOCKERHUB_USER:
description: 'DOCKERHUB_USER'
required: true
DOCKERHUB_TOKEN:
description: 'DOCKERHUB_TOKEN'
required: true
inputs:
image_tag:
description: 'Tag of a built image to deploy'
type: string
required: true

jobs:
build-images:
name: Build and Push Docker Images
env:
image_tag: ${{ inputs.image_tag }}
runs-on: [self-hosted, ci-runner]
steps:
- uses: actions/checkout@v2
- name: setup-env
run: |
echo ZKSYNC_HOME=$(pwd) >> $GITHUB_ENV
echo CI=1 >> $GITHUB_ENV
echo $(pwd)/bin >> $GITHUB_PATH
- name: start-services
run: |
docker-compose -f docker-compose-runner.yml up -d zk postgres
- name: init
run: |
ci_run zk
ci_run zk run yarn
ci_run cp etc/tokens/{test,localhost}.json
ci_run zk run verify-keys unpack
ci_run zk db basic-setup
- name: update-images
run: |
ci_run docker login -u ${{ secrets.DOCKERHUB_USER }} -p ${{ secrets.DOCKERHUB_TOKEN }}
ci_run zk docker push server
- name: docker-down
if: always()
run: |
docker-compose -f docker-compose-runner.yml down

0 comments on commit bfa250d

Please sign in to comment.