Skip to content

Added deployment 14 #19

Added deployment 14

Added deployment 14 #19

Workflow file for this run

name: Deployment
on:
push:
branches:
- deploy2
jobs:
app_deployment:
runs-on: ubuntu-latest
env:
IMAGE_VERSION: "1123"
IMAGE_USERNAME: theoafactor
steps:
- name: 'Checkout the repo'
uses: actions/checkout@v4
- name: "Build an image"
run: |
docker build -t theoafactor/booksfinder:1123 .
- name: 'Log into Docker'
run: |
docker login -u ${{ secrets.DOCKERHUB_USERNAME }} -p ${{ secrets.DOCKERHUB_PASSWORD }}
- name: "Push the image to Docker Hub"
run: |
docker push theoafactor/booksfinder:1123
- name: "SSH into EC2 instance"
env:
SSH_KEY: ${{ secrets.EC2_PRIVATE_KEY }}
run: |
echo "$SSH_KEY" > ssh_key && chmod 600 ssh_key
ssh -o StrictHostKeyChecking=no -i ssh_key [email protected] '
sudo apt-get update &&
# Add Docker's official GPG key:
sudo apt-get update && sudo apt-get install ca-certificates curl && sudo install -m 0755 -d /etc/apt/keyrings && sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc && sudo chmod a+r /etc/apt/keyrings/docker.asc &&
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | &&
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null && sudo apt-get update -y && sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y &&
sudo docker pull theoafactor/booksfinder:1123 &&
sudo docker run -d -p 80:80 theoafactor/booksfinder:1123
'