From 19a9768e0a2ed9244a3ee9b41e9968a3c68ebad6 Mon Sep 17 00:00:00 2001 From: Dimo Pechenikov Date: Fri, 23 May 2025 14:11:48 +0000 Subject: [PATCH] Adding ci-build pipeline --- .github/workflows/ci-deploy.yml | 58 +++++++++++++++++++++++++++++++++ docker-compose.yml | 2 +- 2 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/ci-deploy.yml diff --git a/.github/workflows/ci-deploy.yml b/.github/workflows/ci-deploy.yml new file mode 100644 index 0000000000..0420ddc52d --- /dev/null +++ b/.github/workflows/ci-deploy.yml @@ -0,0 +1,58 @@ +name: Build and Push to Google Artifact Registry + +on: + push: + branches: [ master ] + pull_request: + branches: [ none ] + +jobs: + build-and-push: + if: contains(github.event.head_commit.message, 'CI:Deploy') + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set image tag (timestamp) + id: vars + run: echo "TAG=$(date +'%Y%m%d-%H%M%S')" >> "$GITHUB_OUTPUT" + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Authenticate to Google Cloud + uses: google-github-actions/auth@v2 + with: + credentials_json: '${{ secrets.DOCKER_PASSWORD }}' + + - name: Configure Docker for Artifact Registry + run: | + gcloud auth configure-docker europe-west3-docker.pkg.dev + + - name: Start Geth Devnet container + run: | + docker compose -f ./docker-compose.yml up -d + sleep 5 # Give Geth time to initialize + + - name: Install dependencies + run: | + apt update + apt install -y curl + curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash - + apt install -y nodejs + + - name: Deploy contract to devnet + run: | + cd hardhat.tmpl + node deploy.js + + - name: Commit container state + run: | + docker stop geth-devnet + docker commit geth-devnet europe-west3-docker.pkg.dev/task-460410/task-repo/app:with-contracts + + - name: Push image to Artifact Registry + run: | + docker push europe-west3-docker.pkg.dev/task-460410/task-repo/app:with-contracts \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index b72bfc1d78..38cce3f064 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,7 +2,7 @@ version: "3.8" services: geth-node: - image: app:latest + image: europe-west3-docker.pkg.dev/task-460410/task-repo/app:latest container_name: geth-devnet ports: - "8545:8545" # RPC HTTP