forked from zama-ai/zbc-go-ethereum
-
Notifications
You must be signed in to change notification settings - Fork 1
78 lines (67 loc) · 2.85 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
name: Deploy to EC2
on:
push:
branches:
- build-geth
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Build Geth
run: sudo make build
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Automatic Tagging of Releases
id: increment-git-tag
run: |
bash ./build/git_update.sh -v patch
- name: Log in to Amazon ECR
id: ecr-login
uses: aws-actions/amazon-ecr-login@v1
- name: Build, tag, and push docker image to Amazon ECR
env:
REGISTRY: ${{ steps.ecr-login.outputs.registry }}
REPOSITORY: ${{ secrets.ECR_REPOSITORY }}
IMAGE_TAG: ${{ steps.increment-git-tag.outputs.git-tag }}
run: |
docker build -t $REGISTRY/$REPOSITORY:$IMAGE_TAG .
docker push $REGISTRY/$REPOSITORY:$IMAGE_TAG
- name: Add SSH key
run: |
mkdir -p ~/.ssh
echo "${{ secrets.EC2_PEM_KEY }}" | tr -d '\r' > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
cat ~/.ssh/id_rsa
- name: Add EC2 instance to known hosts
run: ssh-keyscan -H ${{ secrets.EC2_PUBLIC_IP }} >> ~/.ssh/known_hosts
- name: Deploy to EC2
env:
ECR_REGISTRY: ${{ steps.ecr-login.outputs.registry }}
ECR_REPOSITORY: ${{ secrets.ECR_REPOSITORY }}
EC2_USER: ${{ secrets.EC2_USER }}
EC2_PUBLIC_IP: ${{ secrets.EC2_PUBLIC_IP }}
IMAGE_TAG: ${{ steps.increment-git-tag.outputs.git-tag }}
run: |
ssh -o StrictHostKeyChecking=no -i ~/.ssh/id_rsa $EC2_USER@$EC2_PUBLIC_IP << 'EOF'
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin 750262681899.dkr.ecr.us-east-1.amazonaws.com
echo ${{ env.ECR_REGISTRY }}
echo ${{ env.ECR_REPOSITORY }}
echo ${{ env.IMAGE_TAG }}
docker pull ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_TAG }}
docker ps -q | xargs -r docker stop &&
docker ps -aq | xargs -r docker rm &&
docker run -d --name encifher-geth -p 8545:8545 -p 8546:8546 \
${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_TAG }} \
--http --http.api debug,personal,eth,net,web3 \
--http.corsdomain "*" --allow-insecure-unlock \
--dev --datadir store8 --dev.period 2 \
--http.port 8545 --ws --ws.api debug,personal,eth,net,web3 \
--ws.addr 0.0.0.0 --networkid 1337 --ws.port 8546 \
--ws.origins "*" --http.addr 0.0.0.0
EOF