Skip to content

Commit f87f73d

Browse files
Copilotsonnyquinn24
andcommitted
Add ci-cd.yml workflow file
Co-authored-by: sonnyquinn24 <[email protected]>
1 parent 34b2d00 commit f87f73d

File tree

1 file changed

+73
-0
lines changed

1 file changed

+73
-0
lines changed

.github/workflows/ci-cd.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: CI/CD Pipeline
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
workflow_dispatch: # Allows you to manually trigger the workflow
11+
12+
jobs:
13+
build:
14+
name: Build Contracts
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v3
20+
21+
- name: Set up Node.js
22+
uses: actions/setup-node@v3
23+
with:
24+
node-version: 18
25+
26+
- name: Install dependencies
27+
run: npm install
28+
29+
- name: Compile contracts
30+
run: npx hardhat compile
31+
32+
test:
33+
name: Run Tests
34+
runs-on: ubuntu-latest
35+
needs: build # Ensures tests run after build stage
36+
37+
steps:
38+
- name: Checkout code
39+
uses: actions/checkout@v3
40+
41+
- name: Set up Node.js
42+
uses: actions/setup-node@v3
43+
with:
44+
node-version: 18
45+
46+
- name: Install dependencies
47+
run: npm install
48+
49+
- name: Run tests
50+
run: npx hardhat test
51+
52+
deploy:
53+
name: Deploy Contracts
54+
runs-on: ubuntu-latest
55+
needs: test # Ensures deployment runs after tests pass
56+
57+
steps:
58+
- name: Checkout code
59+
uses: actions/checkout@v3
60+
61+
- name: Set up Node.js
62+
uses: actions/setup-node@v3
63+
with:
64+
node-version: 18
65+
66+
- name: Install dependencies
67+
run: npm install
68+
69+
- name: Deploy contracts
70+
run: npx hardhat run scripts/deploy.js --network mainnet
71+
env:
72+
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
73+
INFURA_API_KEY: ${{ secrets.INFURA_API_KEY }}

0 commit comments

Comments
 (0)