From 35f2d0ad0b44816d1ad7fccd250596bd257b0fd7 Mon Sep 17 00:00:00 2001 From: Gibby <503761+Gibby@users.noreply.github.com> Date: Tue, 6 Oct 2020 19:58:08 -0400 Subject: [PATCH] feat: sync tags (#25) * Add option to also sync tags. * Update github-sync.sh Co-authored-by: Gibby Co-authored-by: Wei He Co-authored-by: Wei He --- README.md | 3 ++- action.yml | 4 ++++ github-sync.sh | 7 +++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 69b098261..37f751f08 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![All Contributors](https://img.shields.io/badge/all_contributors-5-orange.svg?style=flat-square)](#contributors-) -A GitHub Action for syncing the current repository using **force push**. +A GitHub Action for syncing the current repository using **force push**. ## Features @@ -11,6 +11,7 @@ A GitHub Action for syncing the current repository using **force push**. * Sync branches from a remote repository * GitHub action can be triggered on a timer or on push * To push to a remote repository, please checkout [git-sync](https://github.com/marketplace/actions/git-sync-action) + * Support syncing tags. ## Usage diff --git a/action.yml b/action.yml index 143a25822..b52f6983d 100644 --- a/action.yml +++ b/action.yml @@ -17,11 +17,15 @@ inputs: github_token: description: GitHub token secret required: true + sync_tags: + description: Should tags also be synced + required: false runs: using: 'docker' image: docker://ghcr.io/repo-sync/github-sync:v2.2.2 env: GITHUB_TOKEN: ${{ inputs.github_token }} + SYNC_TAGS: ${{ inputs.sync_tags }} args: - ${{ inputs.source_repo }} - ${{ inputs.source_branch }}:${{ inputs.destination_branch }} diff --git a/github-sync.sh b/github-sync.sh index 52f5fbd35..bca34ef58 100755 --- a/github-sync.sh +++ b/github-sync.sh @@ -41,6 +41,13 @@ git remote --verbose echo "Pushing changings from tmp_upstream to origin" git push origin "refs/remotes/tmp_upstream/${BRANCH_MAPPING%%:*}:refs/heads/${BRANCH_MAPPING#*:}" --force +if [[ "$SYNC_TAGS" = true ]]; then + echo "Force syncing all tags" + git tag -d $(git tag -l) > /dev/null + git fetch tmp_upstream --tags --quiet + git push origin --tags --force +fi + echo "Removing tmp_upstream" git remote rm tmp_upstream git remote --verbose