Skip to content
This repository has been archived by the owner on Sep 11, 2022. It is now read-only.

Commit

Permalink
🩹 Patch cd pipeline (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
cal-overflow authored Jul 9, 2022
1 parent 16515ca commit 66067a0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
22 changes: 20 additions & 2 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,28 @@ jobs:
EC2_IP_ADDRESS=$(aws cloudformation describe-stacks --stack-name $STACK_NAME --region $REGION --query 'Stacks[0].Outputs[?OutputKey==`IPAddress`].OutputValue' --output text)
ssh -i $KEY_FILE -o "StrictHostKeyChecking no" ubuntu@$EC2_IP_ADDRESS "
# install docker if it does not already exist
if ! [ -x "$(command -v docker)" ]; then
echo "Docker does not yet exist. Updating packages"
echo "Updating packages"
sudo apt-get update
sudo apt-get upgrade -y
echo "Installing docker"
sudo apt-get install docker.io -y
sudo chmod 666 /var/run/docker.sock
echo "Docker install complete"
fi
echo "Pulling docker image ${{ env.DOCKER_IMAGE }}"
docker pull ${{ env.DOCKER_IMAGE }}
# Kill previous container
docker kill \$(docker container ps -q)
if docker container ps -q; then
echo "Killing old docker container"
docker kill \$(docker container ps -q)
fi
echo "Starting container ${{ env.DOCKER_IMAGE }}"
docker run -d -p 80:3000 --restart=unless-stopped ${{ env.DOCKER_IMAGE }}
"
11 changes: 3 additions & 8 deletions template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,9 @@ Resources:
SecurityGroups:
- !Ref SSHSecurityGroup
- !Ref HTTPTrafficSecurityGroup
UserData: !Base64 |
#!/bin/bash -ex
sudo apt-get update
sudo apt upgrade -y
sudo apt install docker.io -y
sudo chmod 666 /var/run/docker.sock
Tags:
- Key: Name
Value: pacman-overflow-ec2

ElasticIP:
Type: AWS::EC2::EIP
Expand Down

0 comments on commit 66067a0

Please sign in to comment.