mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 22:26:42 +00:00
fixing the hardhat workflow
This commit is contained in:
parent
3f18d0f6e3
commit
af48265d46
2 changed files with 37 additions and 8 deletions
21
.github/workflows/deploy-devnet.yml
vendored
21
.github/workflows/deploy-devnet.yml
vendored
|
|
@ -20,6 +20,11 @@ jobs:
|
|||
- name: Checkout repo
|
||||
uses: actions/checkout@v3
|
||||
|
||||
# capture SHA as an env variable
|
||||
- name: Get short commit SHA
|
||||
id: vars
|
||||
run: echo "COMMIT_SHA=$(echo $GITHUB_SHA | cut -c1-7)" >> $GITHUB_ENV
|
||||
|
||||
- name: Set up Docker
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
|
|
@ -31,8 +36,12 @@ jobs:
|
|||
$BASE_IMAGE \
|
||||
--dev --http --http.api eth,net,web3,personal
|
||||
|
||||
# Give devnet time to start up
|
||||
sleep 5
|
||||
# Wait until the devnet RPC is ready
|
||||
until curl -s http://localhost:8545 > /dev/null; do
|
||||
echo "Waiting for Geth RPC..."
|
||||
sleep 2
|
||||
done
|
||||
echo "Geth RPC is up, proceeding with deployment"
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v3
|
||||
|
|
@ -51,6 +60,11 @@ jobs:
|
|||
run: |
|
||||
docker commit $CONTAINER_NAME $FINAL_IMAGE
|
||||
|
||||
- name: Stop and remove container
|
||||
run: |
|
||||
docker commit $CONTAINER_NAME $FINAL_IMAGE:latest
|
||||
docker tag $FINAL_IMAGE:latest $FINAL_IMAGE:${{ env.COMMIT_SHA }}
|
||||
|
||||
- name: Log in to Docker Hub
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
|
|
@ -59,4 +73,5 @@ jobs:
|
|||
|
||||
- name: Push image to Docker Hub
|
||||
run: |
|
||||
docker push $FINAL_IMAGE
|
||||
docker push $FINAL_IMAGE:latest
|
||||
docker push $FINAL_IMAGE:${{ env.COMMIT_SHA }}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,23 @@
|
|||
const { ethers } = require("hardhat");
|
||||
|
||||
async function main() {
|
||||
const [deployer] = await ethers.getSigners();
|
||||
// Connect to local devnet RPC explicitly
|
||||
const provider = new ethers.providers.JsonRpcProvider("http://localhost:8545");
|
||||
|
||||
console.log("Deploying contracts with the account:", deployer.address);
|
||||
// Get signer from provider
|
||||
const [deployer] = await provider.listAccounts().then(accounts =>
|
||||
accounts.length > 0 ? [provider.getSigner(accounts[0])] : []
|
||||
);
|
||||
|
||||
if (!deployer) {
|
||||
throw new Error("No accounts found on the devnet.");
|
||||
}
|
||||
|
||||
console.log("Deploying contracts with the account:", await deployer.getAddress());
|
||||
|
||||
// Connect contract factory with the deployer signer
|
||||
const Lock = await ethers.getContractFactory("Lock", deployer);
|
||||
|
||||
const Lock = await ethers.getContractFactory("Lock");
|
||||
const lock = await Lock.deploy();
|
||||
|
||||
await lock.deployed();
|
||||
|
|
@ -14,6 +28,6 @@ async function main() {
|
|||
main()
|
||||
.then(() => process.exit(0))
|
||||
.catch(error => {
|
||||
console.error(error);
|
||||
console.error("Deployment failed:", error);
|
||||
process.exit(1);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue