Skip to content

Commit

Permalink
Merge pull request #309 from SaintAngeLs/dev
Browse files Browse the repository at this point in the history
#305 add syncronisation with gitlab
  • Loading branch information
SaintAngeLs authored Jul 21, 2024
2 parents 8633299 + 70b38f8 commit 1c0ddef
Show file tree
Hide file tree
Showing 296 changed files with 10,638 additions and 2,602 deletions.
76 changes: 0 additions & 76 deletions .github/workflows/azure_synchronisation.yml

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/build_microservices.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ jobs:
test_dir: 'MiniSpace.Services.Posts/tests'
- project: 'MiniSpace.Services.Comments/src/MiniSpace.Services.Comments.Api'
test_dir: 'MiniSpace.Services.Comments/tests'
- project: 'MiniSpace.Services.Organizations/src/MiniSpace.Services.Organizations.Api'
test_dir: 'MiniSpace.Services.Organizations/tests'
# - project: 'MiniSpace.Services.Organizations/src/MiniSpace.Services.Organizations.Api'
# test_dir: 'MiniSpace.Services.Organizations/tests'
- project: 'MiniSpace.Services.Posts/src/MiniSpace.Services.Posts.Api'
test_dir: 'MiniSpace.Services.Posts/tests'
- project: 'MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Api'
Expand Down
139 changes: 85 additions & 54 deletions .github/workflows/cloud_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,79 +15,110 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up SSH
# - name: Set up SSH
# run: |
# mkdir -p ~/.ssh/
# echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
# chmod 600 ~/.ssh/id_rsa
# ssh-keyscan -H ${{ secrets.DROPLET_IP }} >> ~/.ssh/known_hosts
# cat ~/.ssh/known_hosts

- name: Docker Login
run: |
mkdir -p ~/.ssh/
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh-keyscan -H ${{ secrets.DROPLET_IP }} >> ~/.ssh/known_hosts
cat ~/.ssh/known_hosts
echo ${{ secrets.DOCKER_PASSWORD }} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin
- name: Check the structure
- name: Clone appsettings repository
env:
GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN }}
run: |
pwd
ls -la
cd ./MiniSpace/scripts/
ls -la
git clone https://oauth2:${{ secrets.GITLAB_TOKEN }}@gitlab.com/distributed-asp-net-core-blazor-social-app/events_apsettings_dev.git /tmp/events_public_settings
ls -la /tmp/events_public_settings
- name: Docker Login
- name: Copy appsettings to the correct locations
run: |
echo ${{ secrets.DOCKER_PASSWORD }} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin
cp /tmp/events_public_settings/APIGateway/appsettings.json ./MiniSpace.APIGateway/src/MiniSpace.APIGateway/
cp /tmp/events_public_settings/APIGateway/appsettings.docker.json ./MiniSpace.APIGateway/src/MiniSpace.APIGateway/
cp /tmp/events_public_settings/Services.Comments/appsettings.json ./MiniSpace.Services.Comments/src/MiniSpace.Services.Comments.Api/
cp /tmp/events_public_settings/Services.Comments/appsettings.docker.json ./MiniSpace.Services.Comments/src/MiniSpace.Services.Comments.Api/
cp /tmp/events_public_settings/Services.Email/appsettings.json ./MiniSpace.Services.Email/src/MiniSpace.Services.Email.Api/
cp /tmp/events_public_settings/Services.Email/appsettings.docker.json ./MiniSpace.Services.Email/src/MiniSpace.Services.Email.Api/
cp /tmp/events_public_settings/Services.Events/appsettings.json ./MiniSpace.Services.Events/src/MiniSpace.Services.Events.Api/
cp /tmp/events_public_settings/Services.Events/appsettings.docker.json ./MiniSpace.Services.Events/src/MiniSpace.Services.Events.Api/
cp /tmp/events_public_settings/Services.Friends/appsettings.json ./MiniSpace.Services.Friends/src/MiniSpace.Services.Friends.Api/
cp /tmp/events_public_settings/Services.Friends/appsettings.docker.json ./MiniSpace.Services.Friends/src/MiniSpace.Services.Friends.Api/
cp /tmp/events_public_settings/Services.Identity/appsettings.json ./MiniSpace.Services.Identity/src/MiniSpace.Services.Identity.Api/
cp /tmp/events_public_settings/Services.Identity/appsettings.docker.json ./MiniSpace.Services.Identity/src/MiniSpace.Services.Identity.Api/
cp /tmp/events_public_settings/Services.MediaFiles/appsettings.json ./MiniSpace.Services.MediaFiles/src/MiniSpace.Services.MediaFiles.Api/
cp /tmp/events_public_settings/Services.MediaFiles/appsettings.docker.json ./MiniSpace.Services.MediaFiles/src/MiniSpace.Services.MediaFiles.Api/
cp /tmp/events_public_settings/Services.Notifications/appsettings.json ./MiniSpace.Services.Notifications/src/MiniSpace.Services.Notifications.Api/
cp /tmp/events_public_settings/Services.Notifications/appsettings.docker.json ./MiniSpace.Services.Notifications/src/MiniSpace.Services.Notifications.Api/
cp /tmp/events_public_settings/Services.Organizations/appsettings.json ./MiniSpace.Services.Organizations/src/MiniSpace.Services.Organizations.Api/
cp /tmp/events_public_settings/Services.Organizations/appsettings.docker.json ./MiniSpace.Services.Organizations/src/MiniSpace.Services.Organizations.Api/
cp /tmp/events_public_settings/Services.Posts/appsettings.json ./MiniSpace.Services.Posts/src/MiniSpace.Services.Posts.Api/
cp /tmp/events_public_settings/Services.Posts/appsettings.docker.json ./MiniSpace.Services.Posts/src/MiniSpace.Services.Posts.Api/
cp /tmp/events_public_settings/Services.Reactions/appsettings.json ./MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Api/
cp /tmp/events_public_settings/Services.Reactions/appsettings.docker.json ./MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Api/
cp /tmp/events_public_settings/Services.Reports/appsettings.json ./MiniSpace.Services.Reports/src/MiniSpace.Services.Reports.Api/
cp /tmp/events_public_settings/Services.Reports/appsettings.docker.json ./MiniSpace.Services.Reports/src/MiniSpace.Services.Reports.Api/
cp /tmp/events_public_settings/Services.Students/appsettings.json ./MiniSpace.Services.Students/src/MiniSpace.Services.Students.Api/
cp /tmp/events_public_settings/Services.Students/appsettings.docker.json ./MiniSpace.Services.Students/src/MiniSpace.Services.Students.Api/
cp /tmp/events_public_settings/Web/appsettings.json ./MiniSpace.Web/src/MiniSpace.Web/
cp /tmp/events_public_settings/Web/appsettings.Development.json ./MiniSpace.Web/src/MiniSpace.Web/
ls -la ./MiniSpace/
- name: Run dockerize_all.sh
run: |
chmod +x ./MiniSpace/scripts/dockerize-all.sh
./MiniSpace/scripts/dockerize-all.sh
- name: Check the structure 2
- name: Check the structure
run: |
pwd
ls -la
- name: Test SSH Connection
run: |
ssh -vvv ${{ secrets.DROPLET_USER }}@${{ secrets.DROPLET_IP }} "echo SSH Connection Successful"
- name: Copy and recreate deployment files
run: |
scp -r ./MiniSpace/compose/infrastructure.yml ${{ secrets.DROPLET_USER }}@${{ secrets.DROPLET_IP }}:/root/social_net_app/
scp -r ./MiniSpace/compose/services.yml ${{ secrets.DROPLET_USER }}@${{ secrets.DROPLET_IP }}:/root/social_net_app/
scp -r ./MiniSpace/compose/prometheus ${{ secrets.DROPLET_USER }}@${{ secrets.DROPLET_IP }}:/root/social_net_app/
scp -r ./MiniSpace/compose/rabbitmq ${{ secrets.DROPLET_USER }}@${{ secrets.DROPLET_IP }}:/root/social_net_app/
- name: Deploy containers with the infrastructure images
run: |
ssh -T ${{ secrets.DROPLET_USER }}@${{ secrets.DROPLET_IP }} << EOF
cd /root/social_net_app
docker-compose -f infrastructure.yml up -d
docker ps -a
EOF
- name: Pull latest images for services
run: |
ssh -T ${{ secrets.DROPLET_USER }}@${{ secrets.DROPLET_IP }} << EOF
cd /root/social_net_app
docker-compose -f services.yml pull
EOF
# - name: Test SSH Connection
# run: |
# ssh -vvv ${{ secrets.DROPLET_USER }}@${{ secrets.DROPLET_IP }} "echo SSH Connection Successful"

- name: Deploy containers with the services images
run: |
ssh -T ${{ secrets.DROPLET_USER }}@${{ secrets.DROPLET_IP }} << EOF
cd /root/social_net_app
docker-compose -f services.yml up -d
docker ps -a
EOF
# - name: Copy and recreate deployment files
# run: |
# scp -r ./MiniSpace/compose/infrastructure.yml ${{ secrets.DROPLET_USER }}@${{ secrets.DROPLET_IP }}:/root/social_net_app/
# scp -r ./MiniSpace/compose/services.yml ${{ secrets.DROPLET_USER }}@${{ secrets.DROPLET_IP }}:/root/social_net_app/
# scp -r ./MiniSpace/compose/prometheus ${{ secrets.DROPLET_USER }}@${{ secrets.DROPLET_IP }}:/root/social_net_app/
# scp -r ./MiniSpace/compose/rabbitmq ${{ secrets.DROPLET_USER }}@${{ secrets.DROPLET_IP }}:/root/social_net_app/

# - name: Stop and Remove Containers
# - name: Deploy containers with the infrastructure images
# run: |
# ssh root@${{ secrets.DROPLET_IP }} "docker ps -q --filter network=swiftparcel-network | xargs -r docker stop && docker ps -a -q --filter network=swiftparcel-network | xargs -r docker rm"
# ssh -T ${{ secrets.DROPLET_USER }}@${{ secrets.DROPLET_IP }} << EOF
# cd /root/social_net_app
# docker-compose -f infrastructure.yml up -d
# docker ps -a
# EOF

# - name: Clean up existing Cloud networks
# - name: Pull latest images for services
# run: |
# ssh root@${{ secrets.DROPLET_IP }} "docker network rm swiftparcel-network || true"
# ssh -T ${{ secrets.DROPLET_USER }}@${{ secrets.DROPLET_IP }} << EOF
# cd /root/social_net_app
# docker-compose -f services.yml pull
# EOF

# - name: Deploy to Cloud
# - name: Deploy containers with the services images
# run: |
# scp -r ./SwiftParcel/d-docker-compose root@${{ secrets.DROPLET_IP }}:${{ secrets.CLOUD_PROJECT_PATH }}
# ssh root@${{ secrets.DROPLET_IP }} "cd ${{ secrets.CLOUD_PROJECT_PATH }}/SwiftParcel/d-docker-compose && docker-compose -f ${{ secrets.CLOUD_DEPLOYMENT_FILE }} pull && docker-compose -f ${{ secrets.CLOUD_DEPLOYMENT_FILE }} up -d --force-recreate"
# ssh -T ${{ secrets.DROPLET_USER }}@${{ secrets.DROPLET_IP }} << EOF
# cd /root/social_net_app
# docker-compose -f services.yml up -d
# docker ps -a
# EOF
70 changes: 70 additions & 0 deletions .github/workflows/gitlab_sync.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Sync to GitLab Repositories

on:
push:
branches:
- '*'
pull_request:
types: [closed]
branches:
- '*'

jobs:
Sync:
runs-on: ubuntu-latest
env:
GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_REPO: ${{ github.repository }}
GITLAB_REPO_1: 'SaintAngeLs/distributed_minispace'
GITLAB_REPO_2: 'distributed-asp-net-core-blazor-social-app/distributed_minispace'
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
submodules: true
fetch-depth: 0 # Fetch all branches and tags

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install requests
- name: Configuring git
run: |
git config --global user.email "voznesenskijandrej5@gmail.com"
git config --global user.name "Andrii Voznesenskyi"
- name: Adding GitLab remote repository 1
run: |
GITLAB_REPO="https://oauth2:${{ secrets.GITLAB_TOKEN }}@gitlab.com/SaintAngeLs/distributed_minispace.git"
git remote add gitlab1 $GITLAB_REPO || git remote set-url gitlab1 $GITLAB_REPO
- name: Adding GitLab remote repository 2
run: |
GITLAB_REPO="https://oauth2:${{ secrets.GITLAB_TOKEN }}@gitlab.com/distributed-asp-net-core-blazor-social-app/distributed_minispace.git"
git remote add gitlab2 $GITLAB_REPO || git remote set-url gitlab2 $GITLAB_REPO
- name: Push all branches to both GitLab repositories
run: |
git push gitlab1 --all --force
git push gitlab2 --all --force
- name: Push all tags to both GitLab repositories
run: |
git push gitlab1 --tags --force
git push gitlab2 --tags --force
- name: Sync Pull Requests and Issues to GitLab
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN }}
GITHUB_REPO: ${{ github.repository }}
GITLAB_REPO_1: 'SaintAngeLs/distributed_minispace'
GITLAB_REPO_2: 'distributed-asp-net-core-blazor-social-app/distributed_minispace'
run: python .github/workflows/sync_prs_issues.py
73 changes: 73 additions & 0 deletions .github/workflows/gitlab_sync_pr_issues.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Sync PRs and Issues to GitLab

on:
push:
branches:
- '*'
pull_request:
types: [closed]
branches:
- '*'
schedule:
- cron: '0 * * * *' # Runs every hour
workflow_dispatch:

jobs:
Sync:
runs-on: ubuntu-latest
env:
GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_REPO: ${{ github.repository }}
GITLAB_REPO_1: 'SaintAngeLs/distributed_minispace'
GITLAB_REPO_2: 'distributed-asp-net-core-blazor-social-app/distributed_minispace'
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
submodules: true
fetch-depth: 0 # Fetch all branches and tags

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install requests
- name: Configuring git
run: |
git config --global user.email "voznesenskijandrej5@gmail.com"
git config --global user.name "Andrii Voznesenskyi"
- name: Adding GitLab remote repository 1
run: |
GITLAB_REPO="https://oauth2:${{ secrets.GITLAB_TOKEN }}@gitlab.com/SaintAngeLs/distributed_minispace.git"
git remote add gitlab1 $GITLAB_REPO || git remote set-url gitlab1 $GITLAB_REPO
- name: Adding GitLab remote repository 2
run: |
GITLAB_REPO="https://oauth2:${{ secrets.GITLAB_TOKEN }}@gitlab.com/distributed-asp-net-core-blazor-social-app/distributed_minispace.git"
git remote add gitlab2 $GITLAB_REPO || git remote set-url gitlab2 $GITLAB_REPO
- name: Push all branches to both GitLab repositories
run: |
git push gitlab1 --all --force
git push gitlab2 --all --force
- name: Push all tags to both GitLab repositories
run: |
git push gitlab1 --tags --force
git push gitlab2 --tags --force
- name: Sync Pull Requests and Issues to GitLab
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN }}
GITHUB_REPO: ${{ github.repository }}
GITLAB_REPO_1: 'SaintAngeLs/distributed_minispace'
GITLAB_REPO_2: 'distributed-asp-net-core-blazor-social-app/distributed_minispace'
run: python .github/workflows/sync_prs_issues.py
Loading

0 comments on commit 1c0ddef

Please sign in to comment.