From 2a626edbedafc4078b87e2f1464319a20719054a Mon Sep 17 00:00:00 2001 From: Yaroslav Date: Fri, 3 Nov 2023 09:41:03 +0200 Subject: [PATCH] adding github actions --- .github/workflows/build.yml | 30 ++++++++++++++++++++++ .github/workflows/deploy.yml | 49 ++++++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000000..5c3ef26f34 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,30 @@ +name: Docker Image Build + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + types: [ labeled ] + +jobs: + + build: + if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'CI:Build') + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Build the Docker image + run: docker build . --file Dockerfile + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Build and push + uses: docker/build-push-action@v5 + with: + push: true + tags: vatman/client-go:latest \ No newline at end of file diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000000..4bbbd3e1c3 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,49 @@ +name: Docker Image Deploy + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + types: [ labeled ] + +jobs: + deploy: + if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'CI:Deploy') + + runs-on: ubuntu-latest + + steps: + - name: Checkout Code + uses: actions/checkout@v2 + + - name: Set Up Node.js + uses: actions/setup-node@v3 + with: + node-version: '20.9' + + - name: Start Local Devnet + run: | + docker run -d --name ethereum-node -p 8545:8545 -p 30303:30303 vatman/client-go --dev --http --http.api eth,web3,net --http.corsdomain "http://remix.ethereum.org" + + - name: Deploy Hardhat Project + working-directory: ./hardhat + run: | + npm install --save-dev hardhat + npx hardhat run scripts/deploy.js --network localhost + + - name: Hardhat test + working-directory: ./hardhat + run: npx hardhat test + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Export the Docker image + run: docker commit ethereum-node vatman/client-go-hardhat:latest + + - name: Export and push + run: docker push vatman/client-go-hardhat:latest \ No newline at end of file