Skip to content

Fixed pipeline

Fixed pipeline #3

name: Continuous Deployment
on:
push:
branches:
- main
# Declare variables
env:
APP_NAME: web_app_template
jobs:
build:
name: Build the docker image
runs-on: ubuntu-20.04
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Log in to docker hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build the Docker image
run: docker build . -t ${{ env.APP_NAME }}
- name: Tag the Docker image with latest and the tag name
run: |
echo ${{ github.sha }}
docker tag ${{ env.APP_NAME }} ${{ secrets.DOCKER_USERNAME }}/${{ env.APP_NAME }}:latest
- name: Upload Docker image to Docker Hub
run: docker push ${{ secrets.DOCKER_USERNAME }}/${{ env.APP_NAME }} --all-tags
deploy:
needs: build
name: Deploy to hosted server
runs-on: ubuntu-20.04
steps:
- name: Remote ssh
uses: appleboy/ssh-action@master
with:
host: ${{secrets.SSH_HOST}}
username: ${{secrets.SSH_USERNAME}}
password: ${{secrets.SSH_PASSWORD}}
port: ${{secrets.SSH_PORT}}
script: ${{secrets.SSH_SCRIPT_PATH}}