CI-Deploy #2
Workflow file for this run
This file contains hidden or 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
| name: CI-Deploy | |
| on: | |
| pull_request: | |
| types: [closed] | |
| branches: [master] | |
| permissions: | |
| contents: write | |
| jobs: | |
| deploy-contracts: | |
| if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'CI:Deploy') | |
| runs-on: ubuntu-latest | |
| environment: dev | |
| env: | |
| ENVIRONMENT: dev | |
| REPO_NAME: ${{ github.event.repository.name }} | |
| steps: | |
| - name: Checkout Repo | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: master | |
| - name: Start Geth Devnet | |
| run: | | |
| docker compose up -d | |
| - name: Wait for Geth JSON-RPC | |
| run: | | |
| echo "Waiting for Geth to be ready..." | |
| until curl -s http://localhost:8545; do sleep 1; done | |
| - name: Install Node Modules | |
| working-directory: ./hardhat | |
| run: npm ci | |
| - name: Compile Contracts | |
| working-directory: ./hardhat | |
| run: npx hardhat compile | |
| - name: Deploy Contracts | |
| working-directory: ./hardhat | |
| run: npx hardhat ignition deploy ./ignition/modules/Lock.ts --network local | |
| - name: Autotag | |
| id: autotag | |
| uses: anothrNick/github-tag-action@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| WITH_V: false | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Docker metadata | |
| id: metadata | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.REPO_NAME }} | |
| - name: Fix devnet folder permissions | |
| run: | | |
| sudo chown -R $(id -u):$(id -g) devnet | |
| sudo chmod -R u+rwX devnet | |
| - name: Build and push to Docker Hub | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: Dockerfile.contracts | |
| push: true | |
| tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.REPO_NAME }}:${{ env.ENVIRONMENT }}-contracts-latest,${{ secrets.DOCKERHUB_USERNAME }}/${{ env.REPO_NAME }}:${{ env.ENVIRONMENT }}-contracts-${{ steps.autotag.outputs.tag }} | |
| labels: ${{ steps.metadata.outputs.labels }} | |
| - name: Stop Geth Devnet | |
| run: | | |
| docker compose down | |
| - name: Start Contracts Geth Devnet | |
| run: | | |
| docker run -d \ | |
| -p 8545:8545 \ | |
| -p 30303:30303 \ | |
| ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.REPO_NAME }}:${{ env.ENVIRONMENT }}-contracts-latest \ | |
| --dev \ | |
| --http --http.addr 0.0.0.0 \ | |
| --http.api eth,net,web3 \ | |
| --allow-insecure-unlock | |
| - name: Wait for Contracts Geth JSON-RPC | |
| run: | | |
| echo "Waiting for Contracts Geth to be ready..." | |
| until curl -s http://localhost:8545; do sleep 1; done | |
| - name: Test Contracts | |
| working-directory: ./hardhat | |
| run: npx hardhat test test/Lock.ts --network local | |