Skip to content

Commit

Permalink
feat: exit process when required arguments aren't configured
Browse files Browse the repository at this point in the history
  • Loading branch information
katorly committed Sep 20, 2024
1 parent 03e7205 commit d4c3928
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 14 deletions.
18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,15 @@ jobs:
GITEA_HOST: ${{ secrets.GITEA_HOST }}
GITEA_USERNAME: ${{ secrets.GITEA_USERNAME }}
GITEA_PAT: ${{ secrets.GITEA_PAT }}
CONFIG_CREATE_ORG: true
CONFIG_REMOVE_INEXIST_REPO: false
CONFIG_REMOVE_EXISTING_REPO: false
CONFIG_MIRROR_OWNED: true
CONFIG_MIRROR_FORKED: true
CONFIG_MIRROR_STARRED: false
CONFIG_MIRROR_COLLABORATOR: false
CONFIG_MIRROR_ORGANIZATION: false
CREATE_ORG: true
REMOVE_INEXIST_REPO: false
REMOVE_EXISTING_REPO: false
MIRROR_OWNED: true
MIRROR_PRIVATE: true
MIRROR_FORKED: true
MIRROR_STARRED: false
MIRROR_COLLABORATOR: false
MIRROR_ORGANIZATION: false
RULE_MODE: 'blacklist'
RULE_REGEX: 'EpicGames/.*,NVIDIAGameWorks/.*'
```
Expand Down Expand Up @@ -96,6 +97,7 @@ You can customize these options for mirroring:
| REMOVE_INEXIST_REPO | Remove all repositories in Gitea owned by the user (including those in organizations) that do not exist in GitHub. |
| REMOVE_EXISTING_REPO | Remove existing repositories in Gitea. This will only remove the repositories that have the same name as the repositories in GitHub. You may not want to enable this option, since Gitea will automatically fetch the mirror repositories every 8 hours. |
| MIRROR_OWNED | Mirror the repositories you own. |
| MIRROR_PRIVATE | Mirror private repositories you own. |
| MIRROR_FORKED | Mirror the repositories you forked. |
| MIRROR_STARRED | Mirror the repositories you starred. |
| MIRROR_COLLABORATOR | Mirror the repositories that you have collaborator access. See: https://docs.github.com/zh/rest/repos/repos#list-repositories-for-the-authenticated-user |
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ inputs:
description: 'Mirror the repositories you own'
required: false
default: true
MIRROR_PRIVATE:
description: 'Mirror private repositories you own'
required: false
default: true
MIRROR_FORKED:
description: 'Mirror the repositories you forked'
required: false
Expand Down
43 changes: 37 additions & 6 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,48 @@ git clone https://github.com/katorlys/github-mirror-gitea.git

cd github-mirror-gitea

export GITHUB_PAT=${GITHUB_PAT}
export GITEA_PAT=${GITEA_PAT}
export GITEA_HOST=${GITEA_HOST}
export GITEA_USERNAME=${GITEA_USERNAME}
export GITHUB_USERNAME=${GITHUB_USERNAME}
if [ -n "${GITHUB_USERNAME}" ]; then
export GITHUB_USERNAME=${GITHUB_USERNAME}
else
echo ">> Error: You have to set your GitHub username <<"
exit 1
fi

if [ -n "${GITHUB_PAT}" ]; then
export GITHUB_PAT=${GITHUB_PAT}
else
echo ">> Error: You have to set your GitHub personal access token <<"
exit 1
fi

if [ -n "${GITEA_USERNAME}" ]; then
export GITEA_USERNAME=${GITEA_USERNAME}
else
echo ">> Error: You have to set your Gitea username <<"
exit 1
fi

if [ -n "${GITEA_HOST}" ]; then
export GITEA_HOST=${GITEA_HOST}
else
echo ">> Error: You have to set your Gitea hostname <<"
exit 1
fi

if [ -n "${GITEA_PAT}" ]; then
export GITEA_PAT=${GITEA_PAT}
else
echo ">> Error: You have to set your Gitea personal access token <<"
exit 1
fi

export CREATE_ORG=${CREATE_ORG}
export REMOVE_INEXIST_REPO=${REMOVE_INEXIST_REPO}
export REMOVE_EXISTING_REPO=${REMOVE_EXISTING_REPO}
export MIRROR_OWNED=${MIRROR_OWNED}
export MIRROR_PRIVATE=${MIRROR_PRIVATE}
export MIRROR_FORKED=${MIRROR_FORKED}
export MIRROR_STARED=${MIRROR_STARED}
export MIRROR_STARRED=${MIRROR_STARRED}
export MIRROR_COLLABORATOR=${MIRROR_COLLABORATOR}
export MIRROR_ORGANIZATION=${MIRROR_ORGANIZATION}
export REPO_RULE=${MODE}
Expand Down

0 comments on commit d4c3928

Please sign in to comment.