-
Notifications
You must be signed in to change notification settings - Fork 5
executable file
·50 lines (41 loc) · 1.27 KB
/
continuous-deployment.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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}}