adding github actions

This commit is contained in:
Yaroslav 2023-11-03 09:41:03 +02:00
parent a3be38127c
commit 2a626edbed
2 changed files with 79 additions and 0 deletions

30
.github/workflows/build.yml vendored Normal file
View file

@ -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

49
.github/workflows/deploy.yml vendored Normal file
View file

@ -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