Skip to content

Commit

Permalink
fix ssh command
Browse files Browse the repository at this point in the history
  • Loading branch information
reschandreas committed Dec 26, 2023
1 parent c758c63 commit f1e3b12
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 12 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/build-and-push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ on:
paths-ignore:
- "README.md"
- ".github/workflows/python-**.yaml"
- ".github/workflows/deploy-**.yaml"
- ".github/workflows/json-schema-generation.yaml"

env:
REGISTRY: ghcr.io
Expand All @@ -27,19 +29,43 @@ jobs:
include:
- dockerfile: ./docker/cli/Dockerfile-slim
image: ghcr.io/${{ github.repository }}/cli
watches:
- "docker/cli/**"
- "cli/**"
- dockerfile: ./docker/worker/Dockerfile
image: ghcr.io/${{ github.repository }}/worker
watches:
- "docker/worker/**"
- dockerfile: ./docker/bamboo-generator/Dockerfile
image: ghcr.io/${{ github.repository }}/bamboo-generator
watches:
- "docker/bamboo-generator/**"
- "bamboo-generator/**"
- dockerfile: ./docker/api/Dockerfile-slim
image: ghcr.io/${{ github.repository }}/api
watches:
- "docker/api/**"
- "api/**"
- dockerfile: ./docker/playground/Dockerfile
image: ghcr.io/${{ github.repository }}/playground
watches:
- "docker/playground/**"
- "playground/**"
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- id: files
uses: jitterbit/get-changed-files@v1
with:
format: 'csv'
- run: |
mapfile -d ',' -t added_modified_files < <(printf '%s,' '${{ steps.files.outputs.added_modified }}')
for added_modified_file in "${added_modified_files[@]}"; do
echo "Do something with this ${added_modified_file}."
done
- name: Set up QEMU
uses: docker/setup-qemu-action@v2

Expand Down Expand Up @@ -92,6 +118,7 @@ jobs:
context: .
file: ${{ matrix.dockerfile }}
platforms: linux/amd64,linux/arm64
if: ${{ steps.files.outputs.added_modified.match(matrix.matches) }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ jobs:
- name: Fetch Aeolus Deployment CLI
run: |
wget ${{ env.RAW_URL }}/deployment/aeolus-deployment
wget ${{ env.RAW_URL }}/deployment/aeolus-docker
chmod +x aeolus-deployment
# Configure SSH Key
Expand All @@ -69,17 +70,16 @@ jobs:
env:
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
run: |
ssh -J "$DEPLOYMENT_USER@$DEPLOYMENT_HOST" "$DEPLOYMENT_USER@$DEPLOYMENT_HOST" "mkdir -p $DEPLOYMENT_DIRECTORY"
ssh -J "$GATEWAY_USER@$GATEWAY_HOST" "$DEPLOYMENT_USER@$DEPLOYMENT_HOST" "mkdir -p $DEPLOYMENT_DIRECTORY"
- name: Copy deployment scripts
env:
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
run: |
ls -lah
scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=~/.ssh/known_hosts -o ProxyJump="$GATEWAY_USER@$GATEWAY_HOST" -r deployment "$DEPLOYMENT_USER@$DEPLOYMENT_HOST:$DEPLOYMENT_DIRECTORY"
scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=~/.ssh/known_hosts -o ProxyJump="$GATEWAY_USER@$GATEWAY_HOST" aeolus-docker "$DEPLOYMENT_USER@$DEPLOYMENT_HOST:$DEPLOYMENT_DIRECTORY"
- name: Deploy Aeolus with Docker
env:
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
run: |
$DEPLOYMENT_DIRECTORY/deployment/aeolus-deployment docker-deploy "$DEPLOYMENT_USER@$DEPLOYMENT_HOST" -g "$GATEWAY_USER@$GATEWAY_HOST" -t $DOCKER_TAG -b $BRANCH_NAME -d $DEPLOYMENT_DIRECTORY -y
./aeolus-deployment docker-deploy "$DEPLOYMENT_USER@$DEPLOYMENT_HOST" -g "$GATEWAY_USER@$GATEWAY_HOST" -t $DOCKER_TAG -b $BRANCH_NAME -d $DEPLOYMENT_DIRECTORY -y
2 changes: 1 addition & 1 deletion deployment/aeolus-deployment
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function docker_deploy {
ssh -J "$_gateway_host" -o "StrictHostKeyChecking=no" "$_deployment_host" << COMMAND
mkdir -p $_deployment_directory
cd $_deployment_directory
sudo /usr/bin/bash $_deployment_directory/pyris-docker.sh restart $3 $4
/usr/bin/bash $_deployment_directory/aeolus-docker restart $_pr_tag $_pr_branch
COMMAND
}

Expand Down
14 changes: 7 additions & 7 deletions deployment/aeolus-docker
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Adapted from https://github.com/ls1intum/Pyris
# this script is used to start the Aeolus docker containers, and must be available on the deployment server

PROJECT_DIR="/opt/aeolus/deployment"
PROJECT_DIR="/opt/aeolus/Aeolus/deployment"
COMPOSE_FILE="traefik/docker-compose.yml"
ENV_FILE="/opt/aeolus/docker.env"

Expand All @@ -26,17 +26,17 @@ function start {
local pr_branch=$2

echo "Starting aeolus with PR tag: $pr_tag and branch: $pr_branch"
rm -rf Pyris
rm -rf Aeolus
git clone https://github.com/ls1intum/Aeolus.git -b "$pr_branch" Aeolus
sed -i "s/AEOLUS_DOCKER_TAG=.*/AEOLUS_DOCKER_TAG='$pr_tag'/g" $ENV_FILE
docker compose --project-directory "$PROJECT_DIR" -f "$PROJECT_DIR/$COMPOSE_FILE" --env-file "$ENV_FILE" up -d --pull always --no-build
docker compose -f "$PROJECT_DIR/$COMPOSE_FILE" --env-file "$ENV_FILE" up -d --pull always --no-build
}

function stop {
# TODO: In the future extract pr_tag and pr_branch from env

echo "Stopping aeolus"
docker compose --project-directory "$PROJECT_DIR" -f "$PROJECT_DIR/$COMPOSE_FILE" --env-file "$ENV_FILE" stop pyris-app
docker compose -f "$PROJECT_DIR/$COMPOSE_FILE" --env-file "$ENV_FILE" down
}

function restart {
Expand All @@ -45,15 +45,15 @@ function restart {
}

function aeolus_logs {
docker compose --project-directory "$PROJECT_DIR" -f "$PROJECT_DIR/$COMPOSE_FILE" --env-file "$ENV_FILE" logs -f aeolus-api
docker compose -f "$PROJECT_DIR/$COMPOSE_FILE" --env-file "$ENV_FILE" logs -f aeolus-api
}

function all_logs {
docker compose --project-directory "$PROJECT_DIR" -f "$PROJECT_DIR/$COMPOSE_FILE" --env-file "$ENV_FILE" logs -f
docker compose -f "$PROJECT_DIR/$COMPOSE_FILE" --env-file "$ENV_FILE" logs -f
}

function run_docker_compose_cmd {
docker compose --project-directory "$PROJECT_DIR" -f "$PROJECT_DIR/$COMPOSE_FILE" --env-file "$ENV_FILE" "$@"
docker compose -f "$PROJECT_DIR/$COMPOSE_FILE" --env-file "$ENV_FILE" "$@"
}

# read subcommand `aeolus-docker subcommand server` in variable and remove base command from argument list
Expand Down

0 comments on commit f1e3b12

Please sign in to comment.