Skip to content
This repository has been archived by the owner on Dec 15, 2024. It is now read-only.

docs: add screenshots; add line breaks #49

docs: add screenshots; add line breaks

docs: add screenshots; add line breaks #49

Workflow file for this run

name: Deployment
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install sshpass
run: sudo apt-get install -y sshpass
- name: Set up SSH connection
run: |
mkdir -p ~/.ssh
echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh-keyscan -H ${{ secrets.SERVER_IP }} >> ~/.ssh/known_hosts
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Docker Compose Build
run: |
docker compose build
- name: Get all built Docker image IDs
id: get_image_ids
run: |
IMAGE_IDS=$(docker-compose images -q | tr '\n' ' ')
echo "IMAGE_IDS=$IMAGE_IDS" >> $GITHUB_ENV
- name: Save all Docker images to a tarball
run: |
docker save -o myapp_images.tar ${{ env.IMAGE_IDS }}
- name: Compress the tarball
run: |
gzip myapp_images.tar
- name: Send compressed tarball over SSH
run: |
sshpass -v -p "${{ secrets.SSH_PASSWORD }}" scp myapp_images.tar.gz ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_IP }}:${{ secrets.DEPLOY_PATH }}
- name: Load Docker images on the remote server
run: |
sshpass -v -p "${{ secrets.SSH_PASSWORD }}" ssh ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_IP }} "cd ${{ secrets.DEPLOY_PATH }} && gunzip -c myapp_images.tar.gz | docker load && docker compose down && docker compose up -d"