3
3
mirror of https://github.com/octoleo/octosync.git synced 2024-11-21 20:15:13 +00:00

Moved to octoleo. Adds option to pass config via url.

This commit is contained in:
Llewellyn van der Merwe 2021-07-15 12:29:14 +02:00
parent 150c8767c7
commit 969c9ffc23
Signed by: Llewellyn
GPG Key ID: EFC0C720A240551C
7 changed files with 59 additions and 39 deletions

View File

@ -15,7 +15,7 @@ jobs:
# We use this approach to sign all commits
# Also to use basic git commands in the sync script
# with no further authentication needed
# see: https://github.com/vdm-io/github-user
# see: https://github.com/octoleo/github-user
- name: Setup gitHub User Details
# how to set secrets?
# see: https://docs.github.com/en/actions/reference/encrypted-secrets
@ -38,11 +38,10 @@ jobs:
# A id_ed25519.pub ssh public key liked to the github user account
SSH_PUB: ${{ secrets.SSH_PUB }}
run: |
/bin/bash <(/bin/curl -s https://raw.githubusercontent.com/vdm-io/github-user/master/src/setup.sh) --gpg-key "$GPG_KEY" --gpg-user "$GPG_USER" --ssh-key "$SSH_KEY" --ssh-pub "$SSH_PUB" --git-user "$GIT_USER" --git-email "$GIT_EMAIL" --git-token "$GIT_TOKEN"
- name: Clone Sync Bot Repo
# this is the repo that does the work
run: |
/bin/git clone -b master --single-branch git@github.com:vdm-io/github-sync-bot.git bot
/bin/bash <(/bin/curl -s https://raw.githubusercontent.com/octoleo/github-user/master/src/setup.sh) --gpg-key "$GPG_KEY" --gpg-user "$GPG_USER" --ssh-key "$SSH_KEY" --ssh-pub "$SSH_PUB" --git-user "$GIT_USER" --git-email "$GIT_EMAIL" --git-token "$GIT_TOKEN"
- name: Sync The Repo Files
# you can pass your config by url
# this means you can get your config file from anywhere
# we have --dry added here since we are still in development stage once in production we will remove --dry
run: |
/bin/bash ./bot/src/sync.sh --conf=bot/conf/joomla4.0-dev-lang --dry
/bin/bash <(/bin/curl -s https://raw.githubusercontent.com/octoleo/octoleo/master/src/sync.sh) --conf=https://raw.githubusercontent.com/octoleo/octoleo/master/conf/joomla4.0-dev-lang --dry

View File

@ -14,7 +14,7 @@ jobs:
# We use this approach to sign all commits
# Also to use basic git commands in the sync script
# with no further authentication needed
# see: https://github.com/vdm-io/github-user
# see: https://github.com/octoleo/github-user
- name: Setup gitHub User Details
# how to set secrets?
# see: https://docs.github.com/en/actions/reference/encrypted-secrets
@ -35,11 +35,11 @@ jobs:
# A id_ed25519.pub ssh public key liked to the github user account
SSH_PUB: ${{ secrets.SSH_PUB }}
run: |
/bin/bash <(/bin/curl -s https://raw.githubusercontent.com/vdm-io/github-user/master/src/setup.sh) --gpg-key "$GPG_KEY" --gpg-user "$GPG_USER" --ssh-key "$SSH_KEY" --ssh-pub "$SSH_PUB" --git-user "$GIT_USER" --git-email "$GIT_EMAIL"
- name: Clone Bot Repo
/bin/bash <(/bin/curl -s https://raw.githubusercontent.com/octoleo/github-user/master/src/setup.sh) --gpg-key "$GPG_KEY" --gpg-user "$GPG_USER" --ssh-key "$SSH_KEY" --ssh-pub "$SSH_PUB" --git-user "$GIT_USER" --git-email "$GIT_EMAIL"
- name: Clone Octoleo Repo
# this is the repo that does the work
run: |
/bin/git clone -b master --single-branch git@github.com:vdm-io/github-sync-bot.git bot
/bin/git clone -b master --single-branch git@github.com:octoleo/octoleo.git octoleo
- name: Set Active
run: |
cd bot

View File

@ -15,7 +15,7 @@ jobs:
# We use this approach to sign all commits
# Also to use basic git commands in the sync script
# with no further authentication needed
# see: https://github.com/vdm-io/github-user
# see: https://github.com/octoleo/github-user
- name: Setup gitHub User Details
# how to set secrets?
# see: https://docs.github.com/en/actions/reference/encrypted-secrets
@ -38,11 +38,11 @@ jobs:
# A id_ed25519.pub ssh public key liked to the github user account
SSH_PUB: ${{ secrets.SSH_PUB }}
run: |
/bin/bash <(/bin/curl -s https://raw.githubusercontent.com/vdm-io/github-user/master/src/setup.sh) --gpg-key "$GPG_KEY" --gpg-user "$GPG_USER" --ssh-key "$SSH_KEY" --ssh-pub "$SSH_PUB" --git-user "$GIT_USER" --git-email "$GIT_EMAIL" --git-token "$GIT_TOKEN"
- name: Clone Sync Bot Repo
# this is the repo that does the work
run: |
/bin/git clone -b master --single-branch git@github.com:vdm-io/github-sync-bot.git bot
/bin/bash <(/bin/curl -s https://raw.githubusercontent.com/octoleo/github-user/master/src/setup.sh) --gpg-key "$GPG_KEY" --gpg-user "$GPG_USER" --ssh-key "$SSH_KEY" --ssh-pub "$SSH_PUB" --git-user "$GIT_USER" --git-email "$GIT_EMAIL" --git-token "$GIT_TOKEN"
- name: Sync The Repo Files
# you can pass your config by url
# this means you can get your config file from anywhere
# we have --dry added here since we are still in development stage once in production we will remove --dry
run: |
/bin/bash ./bot/src/sync.sh --conf=bot/conf/lang-joomla4.0-dev --dry
/bin/bash <(/bin/curl -s https://raw.githubusercontent.com/octoleo/octoleo/master/src/sync.sh) --conf=https://raw.githubusercontent.com/octoleo/octoleo/master/conf/lang-joomla4.0-dev --dry

View File

@ -1,5 +1,6 @@
name: "Test Sync Bot"
on:
# so we can manually run a sync test
workflow_dispatch:
@ -10,7 +11,7 @@ jobs:
# We use this approach to sign all commits
# Also to use basic git commands in the sync script
# with no further authentication needed
# see: https://github.com/vdm-io/github-user
# see: https://github.com/octoleo/github-user
- name: Setup gitHub User Details
# how to set secrets?
# see: https://docs.github.com/en/actions/reference/encrypted-secrets
@ -33,12 +34,12 @@ jobs:
# A id_ed25519.pub ssh public key liked to the github user account
SSH_PUB: ${{ secrets.SSH_PUB }}
run: |
/bin/bash <(/bin/curl -s https://raw.githubusercontent.com/vdm-io/github-user/master/src/setup.sh) --gpg-key "$GPG_KEY" --gpg-user "$GPG_USER" --ssh-key "$SSH_KEY" --ssh-pub "$SSH_PUB" --git-user "$GIT_USER" --git-email "$GIT_EMAIL" --git-token "$GIT_TOKEN"
/bin/bash <(/bin/curl -s https://raw.githubusercontent.com/octoleo/github-user/master/src/setup.sh) --gpg-key "$GPG_KEY" --gpg-user "$GPG_USER" --ssh-key "$SSH_KEY" --ssh-pub "$SSH_PUB" --git-user "$GIT_USER" --git-email "$GIT_EMAIL" --git-token "$GIT_TOKEN"
- name: Clone Sync Bot Repo
# this is the repo that does the work
run: |
/bin/git clone -b master --single-branch git@github.com:vdm-io/github-sync-bot.git bot
/bin/git clone -b master --single-branch git@github.com:octoleo/octoleo.git octoleo
- name: Sync The Repo Files
run: |
/bin/bash ./bot/src/sync.sh --conf=bot/conf/joomla4.0-dev-lang --test
/bin/bash ./bot/src/sync.sh --conf=bot/conf/lang-joomla4.0-dev --test
/bin/bash ./octoleo/src/sync.sh --conf=octoleo/conf/joomla4.0-dev-lang --test
/bin/bash ./octoleo/src/sync.sh --conf=octoleo/conf/lang-joomla4.0-dev --test

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
.idea
source_repo
target_repo
config_file_from_url

View File

@ -1,8 +1,17 @@
## Github Sync Bot Setup
# OCTOLEO
- We use this script to setup a github user on the Ubuntu systems in the Github Actions Workflows. See setup instructions below.
- Then the sync of each set of repositories are manage with a config file found in the conf folder.
- So we have to setup multiple workflows for each set repositories (config) you would like to sync.
The option to move files or whole folders from repository to another is what Octoleo does. You can with [configurations](https://github.com/octoleo/octoleo/blob/master/conf/example) setup multiple syncing relationships which you can run in multiple [workflow actions](https://github.com/octoleo/octoleo/blob/master/.github/workflows/test.yml).
## Octoleo Sync Bot Setup
- We use this script to setup a github user on the Ubuntu systems in the Github Actions Workflows. [See setup instructions below](https://github.com/octoleo/octoleo#how-to-setup-github-user).
- Then the sync of each set of repositories are managed with a [config file](https://github.com/octoleo/octoleo/blob/master/conf/example) found in the [conf folder](https://github.com/octoleo/octoleo/blob/master/conf).
- So we can then setup [multiple workflows](https://github.com/octoleo/octoleo/blob/master/.github/workflows) for each set repositories (config) you would like to sync.
Examples:
```yml
```
### How To SETUP gitHub User

View File

@ -5,18 +5,17 @@ command -v git >/dev/null 2>&1 || {
echo >&2 "We require git for this script to run, but it's not installed. Aborting."
exit 1
}
# command -v gh >/dev/null 2>&1 || {
# echo >&2 "We require github CLI for this script to run, but it's not installed. Aborting."
# exit 1
# }
# will still add some github toke check (that it exist)
command -v curl >/dev/null 2>&1 || {
echo >&2 "We require curl for this script to run, but it's not installed. Aborting."
exit 1
}
# get start time
STARTBUILD=$(date +"%s")
# use UTC+00:00 time also called zulu
STARTDATE=$(TZ=":ZULU" date +"%m/%d/%Y @ %R (UTC)")
# BOT name
BOT_NAME="Github Sync Bot v1.0"
BOT_NAME="Octoleo v1.0"
# main function ˘Ô≈ôﺣ
function main() {
@ -166,7 +165,7 @@ function rebaseWithUpstream() {
# just a random remote name
local git_upstream="stroomOp"
# go into repo folder
cd ${git_folder}
cd ${git_folder} || exit 23
# check out the upstream repository
git checkout -b "${git_upstream}" "$git_branch"
git pull ${git_repo_upstream} "$git_branch"
@ -200,7 +199,8 @@ function rebaseWithUpstream() {
fi
fi
# return to original folder
cd "${current_folder}"
cd "${current_folder}" || exit 24
return 0
}
# move the source folders and files to the target folders
@ -605,6 +605,16 @@ while :; do
shift
done
# check if the config is passed via a URL
if [[ "${CONFIG_FILE}" =~ ^"http:" ]] || [[ "${CONFIG_FILE}" =~ ^"https:" ]]; then
if [[ $(wget -S --spider "${CONFIG_FILE}" 2>&1 | grep 'HTTP/1.1 200 OK') ]]; then
wget --quiet "${CONFIG_FILE}" -O config_file_from_url
CONFIG_FILE="config_file_from_url"
else
echo >&2 "The config:${CONFIG_FILE} is not a valid URL. Aborting."
exit 18
fi
fi
# We must have a config file
[ ! -f "${CONFIG_FILE}" ] && echo >&2 "The config:${CONFIG_FILE} is not set or found. Aborting." && exit 18