Skip to content

Commit 52a76a6

Browse files
authored
Merge pull request SvanBoxel#14 from Karlinator/master
Force push if set in environment
2 parents 75d5778 + 3f2a1f4 commit 52a76a6

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ jobs:
2323
with:
2424
args: "https://gitlab.com/<namespace>/<repository>"
2525
env:
26+
FORCE_PUSH: "false"
2627
GITLAB_HOSTNAME: "gitlab.com"
2728
GITLAB_USERNAME: "svboxel"
2829
GITLAB_PASSWORD: ${{ secrets.GITLAB_PASSWORD }} // Generate here: https://gitlab.com/profile/personal_access_tokens
@@ -34,3 +35,5 @@ Be sure to define the `GITLAB_PASSWORD` secret in `https://github.com/<namespace
3435
Before setup a token to use as `GITLAB_PASSWORD` here https://gitlab.com/profile/personal_access_tokens
3536
The token must have `read_api`, `read_repository` & `write_repository` permissions in GitLab.
3637
For granular permissions create seperate users and tokens in GitLab with restricted access.
38+
39+
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`).

entrypoint.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,12 @@ sh -c "git config --global core.askPass /cred-helper.sh"
3131
sh -c "git config --global credential.helper cache"
3232
sh -c "git remote add mirror $*"
3333
sh -c "echo pushing to $branch branch at $(git remote get-url --push mirror)"
34-
sh -c "git push mirror $branch"
34+
if [ "$FORCE_PUSH" = "true" ]
35+
then
36+
sh -c "git push --force mirror $branch"
37+
else
38+
sh -c "git push mirror $branch"
39+
fi
3540

3641
sleep $POLL_TIMEOUT
3742

0 commit comments

Comments
 (0)