Skip to content

Lab Report 2

Lab Report 2 #66

Workflow file for this run

name: CI/CD Pipeline
on:
pull_request:
branches:
- main
types: [closed]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: hasannaber123/fast:1.0.0
- name: SSH into EC2 instance and deploy
uses: appleboy/ssh-action@master
with:
host: ec2-16-16-124-214.eu-north-1.compute.amazonaws.com
username: ubuntu
key: ${{ secrets.EC2_PRIVATE_KEY }}
script: |
sudo docker container stop $(sudo docker container ls -q --filter "publish=80")
sudo docker pull hasannaber123/fast:1.0.0
sudo docker run --network mynetwork -p 80:5000 -d hasannaber123/fast:1.0.0