Skip to content

Test branch

Test branch #33

Workflow file for this run

name: Deploying hardhat
on:
pull_request:
branches: [ "master" ]
types: [ labeled ]
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: san-est/go-ethereum-devops
jobs:
deploy-hardhat:
if: ${{ github.event.label.name == 'CI:Deploy' }}
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
id-token: write
steps:
- uses: actions/checkout@v4
- name: Login to registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Pull image
run: docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
- name: Running image container
run: |
echo "Workspace path: /workspace/hardhat"
docker run -d --name devnet -p 8545:8545 \
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
- name: Copy over hardhat files to running container
run: |
docker exec devnet mkdir -p /workspace/hardhat
docker cp ${{ github.workspace }}/hardhat devnet:/workspace/hardhat
docker exec devnet ls /workspace/hardhat
docker exec devnet ls -l /workspace/hardhat
docker exec devnet ls -l /workspace
#steps were added so i can troublshoot and see if the folder is mounted properly
- name: Installing Node.js and npm
run: |
docker exec devnet apk add --no-cache nodejs npm
- name: Install local version of hardhat
run: docker exec devnet sh -c "cd /workspace/hardhat && npm install hardhat"
- name: Verify if Hardhat is installed
run: |
docker exec devnet npx hardhat --version
- name: Deploy hardhat sample project
run: |
docker exec devnet sh -c "cd /workspace/hardhat && npx hardhat ignition deploy ./ignition/modules/Lock.js"
- name: Testing contracts
run: |
docker exec devnet sh -c "cd /workspace/hardhat && npx hardhat test"
- name: Build a new docker image
run: |
docker commit devnet go-eth-hardhat:latest
docker tag go-eth-hardhat:latest ${{ env.REGISTRY }}/${{ github.repository_owner }}/go-eth-hardhat:latest
- name: Push new image to ghcr.io
run: docker push ${{ env.REGISTRY }}/${{ github.repository_owner }}/go-eth-hardhat:latest