-
Notifications
You must be signed in to change notification settings - Fork 20.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
103 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
name: CI Build and Push Docker Image | ||
|
||
on: | ||
pull_request: | ||
types: [closed] # Trigger when the PR is closed (merged or just closed) | ||
branches: | ||
- master # Trigger only when code is pushed to the master branch | ||
|
||
jobs: | ||
build: | ||
# Run the jobs only if the PR is merged and the label 'CI:Build' is present | ||
if: contains(github.event.pull_request.labels.*.name, 'CI:Build') && github.event.pull_request.merged == true | ||
runs-on: ubuntu:latest | ||
|
||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Get Version and Build number | ||
run: | | ||
VERSION="latest" # Simple static version; could be changed if needed | ||
BUILDNUM=${GITHUB_RUN_NUMBER} # Use the GitHub run number as the build number | ||
# Set environment variables for later steps | ||
echo "VERSION=${VERSION}" >> $GITHUB_ENV | ||
echo "BUILDNUM=${BUILDNUM}" >> $GITHUB_ENV | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Set up Docker Login | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
|
||
- name: Build Docker image | ||
run: | | ||
docker build -t ${{ secrets.DOCKER_USERNAME }}/go-ethereum:${{ env.BUILDNUM }} . | ||
- name: Tag Docker image with 'latest' | ||
run: | | ||
docker tag ${{ secrets.DOCKER_USERNAME }}/go-ethereum:${{ env.BUILDNUM }} ${{ secrets.DOCKER_USERNAME }}/go-ethereum:latest | ||
- name: Push Docker image to Docker Hub | ||
run: | | ||
docker push ${{ secrets.DOCKER_USERNAME }}/go-ethereum:${{ env.BUILDNUM }} | ||
docker push ${{ secrets.DOCKER_USERNAME }}/go-ethereum:latest | ||
run-devnet: | ||
needs: build # Ensure this runs only after the build-and-push job | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Docker Compose | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y docker-compose | ||
- name: Log in to Docker Hub | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
|
||
- name: Run Devnet with Docker Compose | ||
run: | | ||
export DOCKER_HUB_USER=${{ secrets.DOCKER_USERNAME }} | ||
docker-compose up -d | ||
- name: Verify Devnet | ||
run: | | ||
sleep 10 # Allow time for the devnet to start | ||
curl -X POST -H "Content-Type: application/json" \ | ||
--data '{"jsonrpc":"2.0","method":"web3_clientVersion","params":[],"id":1}' \ | ||
http://localhost:8545 | ||
- name: Stop Devnet container | ||
run: | | ||
docker-compose down # Stops the containers and removes the network |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
services: | ||
devnet: | ||
image: $DOCKER_HUB_USER/go-ethereum:latest # Use the image built and pushed during build phase | ||
container_name: devnet | ||
ports: | ||
- "8545:8545" # Exposing RPC endpoint for interaction | ||
command: ["geth", "--dev", "--http", "--http.api", "web3,eth,net,personal", "--http.addr", "0.0.0.0", "--http.port", "8545"] | ||
networks: | ||
- devnet_network | ||
|
||
networks: | ||
devnet_network: | ||
driver: bridge |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters