forked from ethereum/go-ethereum
-
Notifications
You must be signed in to change notification settings - Fork 0
85 lines (69 loc) · 3.32 KB
/
docker-pipeline.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
name: Build and Push Docker Image
on:
pull_request:
types: [closed]
jobs:
# This job is triggered on merged PRs with the CI:Build label
# It builds a Docker image with a local geth devnet and pushes it to Docker Hub
build-and-push-docker-image:
if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'CI:Build')
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_ACCESS_TOKEN }}
- name: Build and push Docker image
run: |
COMMIT=$(git rev-parse --short HEAD)
VERSION=$(git describe --tags --abbrev=0)
BUILDNUM=${{ github.run_number }}
docker build --build-arg COMMIT=$COMMIT --build-arg VERSION=$VERSION --build-arg BUILDNUM=$BUILDNUM -t ${{ secrets.DOCKER_USERNAME }}/go-ethereum-fork:latest .
docker push ${{ secrets.DOCKER_USERNAME }}/go-ethereum-fork:latest
# This job is triggered on merged PRs with the CI:Deploy label
# It runs a local geth devnet container in daemon mode using docker-compose with the image built in the previous job
# A sample hardhat project is mounted to the container from the hardhat directory
# The sample contract is deployed on the local geth devnet and tested
# After that, a new image with the contract is built and pushed to Docker Hub
hardhat-deploy-and-test:
if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'CI:Deploy')
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_ACCESS_TOKEN }}
- name: Install Docker Compose
run: |
sudo curl -SL https://github.com/docker/compose/releases/download/v2.29.1/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose --version
- name: Run local geth devnet container in daemon mode
run: |
docker-compose -f docker-compose.yml up -d geth-node
# Wait for geth to be ready
sleep 10
- name: Copy entrypoint and the hardhat directory containing the sample project
run: |
docker cp ./hardhat ethereum-node:/hardhat
docker cp ./entrypoint.sh ethereum-node:/entrypoint.sh
docker exec ethereum-node chmod +x /entrypoint.sh
- name: Compile and deploy contracts inside the container by running the entrypoint script
run: |
docker exec ethereum-node sh /entrypoint.sh
- name: Commit the container state to a new Docker image and push it to Docker Hub
run: |
docker commit ethereum-node ${{ secrets.DOCKER_USERNAME }}/go-ethereum-fork:deployed
docker push ${{ secrets.DOCKER_USERNAME }}/go-ethereum-fork:deployed
- name: Stop and remove the geth-node container
run: docker-compose -f docker-compose.yml down