updated workflow #14
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: 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 }} | |
IMAGE_TAG: v0.3.15 | |
DOCKER_IMAGE: ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_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 }} | |
echo ${{ env.DOCKER_IMAGE }} | |
docker pull ${{ env.DOCKER_IMAGE }} | |
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.DOCKER_IMAGE }} \ | |
--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 |