Lab Report 2 #66
Workflow file for this run
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: 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 |