Skip to content

Commit

Permalink
feat: sync tags (#25)
Browse files Browse the repository at this point in the history
* Add option to also sync tags.

* Update github-sync.sh

Co-authored-by: Gibby <git@twoitguys>
Co-authored-by: Wei He <[email protected]>
Co-authored-by: Wei He <[email protected]>
  • Loading branch information
4 people authored Oct 6, 2020
1 parent 414300b commit 35f2d0a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
[![All Contributors](https://img.shields.io/badge/all_contributors-5-orange.svg?style=flat-square)](#contributors-)
<!-- ALL-CONTRIBUTORS-BADGE:END -->

A GitHub Action for syncing the current repository using **force push**.
A GitHub Action for syncing the current repository using **force push**.


## Features
* Sync branches between two GitHub repositories
* 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
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
7 changes: 7 additions & 0 deletions github-sync.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 35f2d0a

Please sign in to comment.