-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1f869de
commit 4df8113
Showing
1 changed file
with
35 additions
and
29 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,42 @@ | ||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
name: 'main' | ||
on: | ||
push: | ||
branches: [main] | ||
paths: | ||
- './**' | ||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Build Docker image | ||
run: docker build -t my-image:latest . | ||
- name: Build Docker image | ||
run: docker build -t my-image:latest . | ||
|
||
- name: Save Docker image as tar file | ||
run: docker save -o my-image.tar my-image:latest | ||
- name: Save Docker image as tar file | ||
run: docker save -o my-image.tar my-image:latest | ||
|
||
- name: Transfer Docker image to remote server | ||
run: | | ||
mkdir -p ~/.ssh | ||
echo "${{ secrets.PRIVATE_KEY }}" > ~/.ssh/id_rsa | ||
chmod 600 ~/.ssh/id_rsa | ||
scp -o StrictHostKeyChecking=no my-image.tar ${{ secrets.REMOTE_SERVER_USERNAME }}@${{ secrets.REMOTE_SERVER_ADDRESS }}:${{ secrets.REMOTE_SERVER_PATH }} | ||
- name: Transfer Docker image to remote server | ||
run: | | ||
mkdir -p ~/.ssh | ||
echo "${{ secrets.PRIVATE_KEY }}" > ~/.ssh/id_rsa | ||
chmod 600 ~/.ssh/id_rsa | ||
scp -o StrictHostKeyChecking=no my-image.tar ${{ secrets.REMOTE_SERVER_USERNAME }}@${{ secrets.REMOTE_SERVER_ADDRESS }}:${{ secrets.REMOTE_SERVER_PATH }} | ||
- name: Load Docker image on remote server | ||
run: | | ||
ssh -o StrictHostKeyChecking=no ${{ secrets.REMOTE_SERVER_USERNAME }}@${{ secrets.REMOTE_SERVER_ADDRESS }} << 'ENDSSH' | ||
docker load -i ${{ secrets.REMOTE_SERVER_PATH }}/my-image.tar | ||
ENDSSH | ||
- name: Load Docker image on remote server | ||
run: | | ||
ssh -o StrictHostKeyChecking=no ${{ secrets.REMOTE_SERVER_USERNAME }}@${{ secrets.REMOTE_SERVER_ADDRESS }} << 'ENDSSH' | ||
docker load -i ${{ secrets.REMOTE_SERVER_PATH }}/my-image.tar | ||
ENDSSH | ||
- name: Transfer Docker Compose file to remote server | ||
run: | | ||
scp -o StrictHostKeyChecking=no docker-compose.yml ${{ secrets.REMOTE_SERVER_USERNAME }}@${{ secrets.REMOTE_SERVER_ADDRESS }}:${{ secrets.REMOTE_SERVER_PATH }} | ||
- name: Transfer Docker Compose file to remote server | ||
run: | | ||
scp -o StrictHostKeyChecking=no docker-compose.yml ${{ secrets.REMOTE_SERVER_USERNAME }}@${{ secrets.REMOTE_SERVER_ADDRESS }}:${{ secrets.REMOTE_SERVER_PATH }} | ||
- name: Deploy Docker containers using Docker Compose on remote server | ||
run: | | ||
ssh -o StrictHostKeyChecking=no ${{ secrets.REMOTE_SERVER_USERNAME }}@${{ secrets.REMOTE_SERVER_ADDRESS }} << 'ENDSSH' | ||
docker-compose -f ${{ secrets.REMOTE_SERVER_PATH }}/docker-compose.yml up -d | ||
ENDSSH | ||
- name: Deploy Docker containers using Docker Compose on remote server | ||
run: | | ||
ssh -o StrictHostKeyChecking=no ${{ secrets.REMOTE_SERVER_USERNAME }}@${{ secrets.REMOTE_SERVER_ADDRESS }} << 'ENDSSH' | ||
docker-compose -f ${{ secrets.REMOTE_SERVER_PATH }}/docker-compose.yml up -d | ||
ENDSSH |