From 89493e6ebabf162251d512cd0bc5394c4bd68300 Mon Sep 17 00:00:00 2001 From: sergey filyanin Date: Wed, 20 Sep 2023 16:42:42 +0200 Subject: [PATCH] Add workflow to check changes on validator (#3303) Co-authored-by: Nikolay Volf --- .github/workflows/validation.yml | 69 ++++++++++++++++++++++++++++++++ docker/Dockerfile | 2 +- 2 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/validation.yml diff --git a/.github/workflows/validation.yml b/.github/workflows/validation.yml new file mode 100644 index 00000000000..09ca0e73dc1 --- /dev/null +++ b/.github/workflows/validation.yml @@ -0,0 +1,69 @@ +name: Live check on Vara Network Validator machine + +on: + pull_request: + types: [synchronize, labeled, opened, reopened, ready_for_review] + branches: [master] + workflow_dispatch: + +env: + CARGO_TERM_COLOR: always + +jobs: + tag-image: + runs-on: ubuntu-latest + if: contains(github.event.pull_request.labels.*.name, 'check-validator') + outputs: + image_tag: ${{ steps.image-tag.outputs.tag }} + steps: + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Create image tag + id: image-tag + run: echo "tag=ghcr.io/gear-tech/node:0.1.0-`echo ${GITHUB_SHA} | cut -c1-8`" >> $GITHUB_OUTPUT + + build-update-validator: + runs-on: [kuberunner] + if: contains(github.event.pull_request.labels.*.name, 'check-validator') + needs: tag-image + steps: + + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Echo tag + run: echo ${{ needs.tag-image.outputs.image_tag }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to DockerHub + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push + id: docker_build + uses: docker/build-push-action@v4 + with: + context: . + file: ./docker/Dockerfile + push: true + tags: ghcr.io/gear-tech/node:latest, ${{ needs.tag-image.outputs.image_tag }} + + - name: SSH into VM + uses: appleboy/ssh-action@v1.0.0 + env: + NEW_IMAGE: ${{ needs.tag-image.outputs.image_tag }} + with: + host: ${{ secrets.VARA_VALIDATOR_8 }} + username: ${{ secrets.SSH_VARA_USERNAME }} + key: ${{ secrets.VARA_SSH_PRIVATE_KEY }} + envs: NEW_IMAGE + script: | + sudo docker-compose -f /home/gear/docker-compose.yaml down + awk -v new_image="$NEW_IMAGE" '{gsub(/image: ghcr.io\/gear-tech\/node:.*/, "image: " new_image)}1' /home/gear/docker-compose.yaml > tmp && mv tmp /home/gear/docker-compose.yaml + sudo docker-compose -f /home/gear/docker-compose.yaml up -d diff --git a/docker/Dockerfile b/docker/Dockerfile index a36437d090c..c15e2bd8d13 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -37,7 +37,7 @@ RUN cargo build -p gear-cli --profile $PROFILE # ===== SECOND STAGE ====== -FROM ubuntu:22.10 +FROM ubuntu:22.04 MAINTAINER GEAR LABEL description="This is the 2nd stage: a very small image where we copy the Gear binary." ARG PROFILE=production