testing build and deploy #2
This file contains 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: Encifher Geth CI/CD Pipeline | |
on: | |
push: | |
branches: [build-geth] | |
jobs: | |
Deploy: | |
name: Deploy to EC2 | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v3 | |
- name: Build Geth | |
run: make build | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build and push Docker image | |
env: | |
DOCKER_IMAGE: anikep/encifher-geth:${{ github.sha }} | |
run: | | |
docker build -t $DOCKER_IMAGE . | |
docker push $DOCKER_IMAGE | |
- name: Deploy | |
env: | |
PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} | |
HOSTNAME: ${{secrets.SSH_HOST}} | |
USER_NAME: ${{secrets.USER_NAME}} | |
DOCKER_IMAGE: anikep/encifher-geth:${{ github.sha }} | |
run: | | |
echo "$PRIVATE_KEY" > private_key && chmod 600 private_key | |
ssh -o StrictHostKeyChecking=no -i private_key ${USER_NAME}@${HOSTNAME} ' | |
# Now we have got the access of EC2 and we will start the deploy . | |
cd /home/ubuntu/encifher-geth && | |
sudo docker stop $(sudo docker ps -aq) && | |
sudo docker rm $(sudo docker ps -aq) && | |
sudo docker pull ${{ env.DOCKER_IMAGE }} && | |
sudo docker run -d --name encifher-geth \ | |
-p 8545:8545 -p 8546:8546 \ | |
-v /home/ubuntu/encifher-geth/store8:/root/.ethereum \ | |
${{ env.DOCKER_IMAGE }} \ | |
--http --http.api debug,personal,eth,net,web3 \ | |
--http.corsdomain "*" --allow-insecure-unlock \ | |
--dev --datadir /root/.ethereum --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 | |
' |