Skip to content

Commit

Permalink
Update deploy.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
KBA07 committed May 31, 2023
1 parent 2b63c56 commit b6c99f4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 18 deletions.
35 changes: 18 additions & 17 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,26 @@ on:
jobs:
start:
runs-on: ubuntu-latest
environment: AWS-EC2-T2-MICRO

steps:
- uses: actions/checkout@v2

- name: AWS SSM Send-Command
uses: peterkimzz/aws-ssm-send-command@master
id: ssm
with:
aws-region: ${{ secrets.AWS_REGION }}
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
instance-ids: ${{ secrets.INSTANCE_ID }}

working-directory: /home/ubuntu/deployment
command: /bin/sh ./deploy.sh

# Catch SSM outputs
# - name: Get the outputs
# run: echo "The Command id is ${{ steps.ssm.outputs.command-id }}"
- name: Check out code
uses: actions/checkout@v2

- name: Deploy
run: echo "Deployment to AWS EC2 is beggining..."

- name: Deploy in EC2
env:
PRIVATE_KEY: ${{ secrets.AWS_EC2_PRIVATE_KEY }}
HOST_NAME : ${{ secrets.AWS_EC2_HOST }}
USER_NAME : ubuntu

run: |
echo "$PRIVATE_KEY" > private_key && chmod 600 private_key
ssh -o StrictHostKeyChecking=no -i private_key ${USER_NAME}@${HOST_NAME} 'bash -s' < deploy.sh
echo "removing the stored key from the machine"
rm -f private_key
## Setting up your Domain

Expand Down
2 changes: 1 addition & 1 deletion deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ else
fi

echo "stopping the existing container: $CONTAINER_NAME"
docker stop $CONTAINER_NAME
docker rm -f $CONTAINER_NAME
echo "starting a new container: $CONTAINER_NAME"
docker run --name $CONTAINER_NAME -p 80:8081 -p 443:8081 -d $IMAGE_NAME

0 comments on commit b6c99f4

Please sign in to comment.