-
Notifications
You must be signed in to change notification settings - Fork 8
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
Showing
5 changed files
with
92 additions
and
2 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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: Deploy Docker with bash file | ||
|
||
on: | ||
workflow_run: | ||
workflows: ['Build and push Docker - disabled'] | ||
types: | ||
- completed | ||
|
||
workflow_dispatch: | ||
|
||
env: | ||
IMAGE_NAME_WITH_TAG: ${{ secrets.DOCKER_USERNAME }}/${{ github.event.repository.name }}:latest | ||
|
||
jobs: | ||
deploy: | ||
name: Deploy image from Dockerhub to remote host with ssh | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Set up SSH config | ||
run: | | ||
# Set up SSH key | ||
mkdir -p ~/.ssh | ||
echo "${{ secrets.REMOTE_KEY_ED25519 }}" > ~/.ssh/id_ed25519 | ||
chmod 600 ~/.ssh/id_ed25519 | ||
# Set up SSH config | ||
echo "Host arm1" > ~/.ssh/config | ||
echo " HostName ${{ secrets.REMOTE_HOST }}" >> ~/.ssh/config | ||
echo " User ${{ secrets.REMOTE_USERNAME }}" >> ~/.ssh/config | ||
echo " IdentityFile ~/.ssh/id_ed25519" >> ~/.ssh/config | ||
echo " Port ${{ secrets.REMOTE_PORT }}" >> ~/.ssh/config | ||
chmod 600 ~/.ssh/config | ||
# Add SSH server key to known_hosts | ||
ssh-keyscan -H ${{ secrets.REMOTE_HOST }} >> ~/.ssh/known_hosts | ||
- name: Run bash file with yarn | ||
run: yarn deploy:docker |
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/bash | ||
|
||
REMOTE_HOST=$1 | ||
REMOTE_PATH=$2 | ||
IMAGE_NAME_WITH_TAG=$3 | ||
|
||
# Check if all arguments are provided | ||
if [[ -z "$REMOTE_PATH" || -z "$REMOTE_HOST" || -z "$IMAGE_NAME_WITH_TAG" ]]; then | ||
echo "Incorrect args, usage: $0 <remote_path> <remote_host> <image_name>" | ||
exit 1 | ||
fi | ||
|
||
# Navigate to the docker-compose.yml folder | ||
ssh $REMOTE_HOST "cd $REMOTE_PATH && \ | ||
docker compose down && \ | ||
docker image rm $IMAGE_NAME_WITH_TAG && \ | ||
docker compose up -d" | ||
|
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
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/bin/bash | ||
|
||
# REMOTE_PATH="~/traefik-proxy/apps/nmc-docker" | ||
# REMOTE_HOST="arm1" | ||
|
||
REMOTE_HOST=$1 | ||
REMOTE_PATH=$2 | ||
IMAGE_NAME_WITH_TAG=$3 | ||
|
||
# Check if all arguments are provided | ||
if [[ -z "$REMOTE_PATH" || -z "$REMOTE_HOST" || -z "$IMAGE_NAME_WITH_TAG" ]]; then | ||
echo "Incorrect args, usage: $0 <remote_path> <remote_host> <image_name>" | ||
exit 1 | ||
fi | ||
|
||
# Navigate to the docker-compose.yml folder | ||
ssh $REMOTE_HOST "cd $REMOTE_PATH && \ | ||
echo 'Old image id:' && \ | ||
\$(docker image ls --format='{{.Repository}}:{{.ID}}' | grep '$IMAGE_NAME_WITH_TAG') | ||
docker compose down && \ | ||
docker image rm '$IMAGE_NAME_WITH_TAG' && \ | ||
docker compose up -d && \ | ||
echo 'New image id:' && \ | ||
\$(docker image ls --format='{{.Repository}}:{{.ID}}' | grep '$IMAGE_NAME_WITH_TAG')" | ||
|
File renamed without changes.