Skip to content

Commit

Permalink
Merge pull request #14 from Karlinator/master
Browse files Browse the repository at this point in the history
Force push if set in environment
  • Loading branch information
SvanBoxel authored Jul 29, 2022
2 parents 75d5778 + 3f2a1f4 commit 52a76a6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:
with:
args: "https://gitlab.com/<namespace>/<repository>"
env:
FORCE_PUSH: "false"
GITLAB_HOSTNAME: "gitlab.com"
GITLAB_USERNAME: "svboxel"
GITLAB_PASSWORD: ${{ secrets.GITLAB_PASSWORD }} // Generate here: https://gitlab.com/profile/personal_access_tokens
Expand All @@ -34,3 +35,5 @@ Be sure to define the `GITLAB_PASSWORD` secret in `https://github.com/<namespace
Before setup a token to use as `GITLAB_PASSWORD` here https://gitlab.com/profile/personal_access_tokens
The token must have `read_api`, `read_repository` & `write_repository` permissions in GitLab.
For granular permissions create seperate users and tokens in GitLab with restricted access.

If you're rewriting history in the primary repo (e.g by using `git rebase`), you'll need to force push. Set the `FORCE_PUSH` environment variable to `true` to enable this. This will overwrite history in the mirror as well, so be **careful with this** (just like any time you're using `git push --force`).
7 changes: 6 additions & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@ sh -c "git config --global core.askPass /cred-helper.sh"
sh -c "git config --global credential.helper cache"
sh -c "git remote add mirror $*"
sh -c "echo pushing to $branch branch at $(git remote get-url --push mirror)"
sh -c "git push mirror $branch"
if [ "$FORCE_PUSH" = "true" ]
then
sh -c "git push --force mirror $branch"
else
sh -c "git push mirror $branch"
fi

sleep $POLL_TIMEOUT

Expand Down

0 comments on commit 52a76a6

Please sign in to comment.