Skip to content

Commit

Permalink
Merge pull request SvanBoxel#19 from grogou/master
Browse files Browse the repository at this point in the history
Add tags mirror functionality
  • Loading branch information
SvanBoxel authored Jan 26, 2023
2 parents 871fb56 + 1f4a916 commit da9671d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
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:
FOLLOW_TAGS: "false"
FORCE_PUSH: "false"
GITLAB_HOSTNAME: "gitlab.com"
GITLAB_USERNAME: "svboxel"
Expand All @@ -37,3 +38,5 @@ The token must have `read_api`, `read_repository` & `write_repository` permissio
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`).

If you want to mirror repository tags too, you can define `FOLLOW_TAGS` environment variable to `true`.
6 changes: 6 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ else
sh -c "git push mirror $branch"
fi

if [ "${FOLLOW_TAGS:-}" = "true" ]
then
sh -c "echo pushing with --tags"
sh -c "git push --tags mirror $branch"
fi

sleep $POLL_TIMEOUT

pipeline_id=$(curl --header "PRIVATE-TOKEN: $GITLAB_PASSWORD" --silent "https://${GITLAB_HOSTNAME}/api/v4/projects/${GITLAB_PROJECT_ID}/repository/commits/${branch_uri}" | jq '.last_pipeline.id')
Expand Down

0 comments on commit da9671d

Please sign in to comment.