├── .github ├── dependabot.yml ├── renovate.json └── workflows │ ├── test.yml │ ├── check.yml │ └── build.yml ├── entrypoint.sh ├── action.yml ├── license.md └── readme.md /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: "github-actions" 4 | directory: "/" 5 | schedule: 6 | interval: "daily" 7 | -------------------------------------------------------------------------------- /.github/renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://docs.renovatebot.com/renovate-schema.json", 3 | "extends": [ 4 | "config:recommended", 5 | ":disableDependencyDashboard" 6 | ], 7 | "forkProcessing": "enabled" 8 | } 9 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | on: 2 | pull_request: 3 | paths: 4 | - '**/*.sh' 5 | - '.github/workflows/test.yml' 6 | - '.github/workflows/check.yml' 7 | 8 | name: "Test" 9 | permissions: {} 10 | 11 | jobs: 12 | shellcheck: 13 | uses: ./.github/workflows/check.yml 14 | -------------------------------------------------------------------------------- /.github/workflows/check.yml: -------------------------------------------------------------------------------- 1 | on: [workflow_call] 2 | name: "Check" 3 | permissions: {} 4 | 5 | jobs: 6 | shellcheck: 7 | name: shellcheck 8 | runs-on: ubuntu-latest 9 | steps: 10 | - uses: actions/checkout@v5 11 | - name: Run ShellCheck 12 | uses: ludeeus/action-shellcheck@master 13 | env: 14 | SHELLCHECK_OPTS: -x 15 | -------------------------------------------------------------------------------- /entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | echo "${GITHUB_EVENT_NAME}" 5 | 6 | function git-setup() { 7 | printf -v url "https://%s:%s@%s" \ 8 | "${INPUT_TARGET_USERNAME}" \ 9 | "${INPUT_TARGET_TOKEN}" \ 10 | "${INPUT_TARGET_URL#https://}" 11 | echo "git remote add target ${url}" 12 | git remote add target "${url}" 13 | set -x 14 | } 15 | 16 | case "${GITHUB_EVENT_NAME}" in 17 | push|create|pull_request|workflow_dispatch|workflow_run) 18 | git-setup 19 | git fetch --all 20 | git push -f --all target 21 | git push -f --prune target 22 | git push -f --tags target 23 | ;; 24 | delete) 25 | git-setup 26 | git push -d target "${GITHUB_EVENT_REF}" 27 | ;; 28 | *) 29 | #break 30 | esac 31 | 32 | -------------------------------------------------------------------------------- /action.yml: -------------------------------------------------------------------------------- 1 | name: "Gitlab Sync" 2 | author: "action-pack" 3 | description: "Action to mirror a repository to GitLab." 4 | 5 | branding: 6 | icon: "copy" 7 | color: "gray-dark" 8 | 9 | inputs: 10 | url: 11 | description: "GitLab repo URL" 12 | required: true 13 | username: 14 | description: "GitLab username" 15 | required: true 16 | token: 17 | description: "GitLab token" 18 | required: true 19 | runs: 20 | using: "composite" 21 | steps: 22 | - run: ${{ github.action_path }}/entrypoint.sh 23 | shell: bash 24 | env: 25 | INPUT_TARGET_URL: ${{ inputs.url }} 26 | INPUT_TARGET_TOKEN: ${{ inputs.token }} 27 | INPUT_TARGET_USERNAME: ${{ inputs.username }} 28 | GITHUB_EVENT_REF: ${{ github.event.ref }} 29 | -------------------------------------------------------------------------------- /license.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. 20 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 |

Gitlab Sync
2 |
3 | 4 | [![Build](https://github.com/action-pack/gitlab-sync/workflows/Build/badge.svg)](https://github.com/action-pack/gitlab-sync/) 5 | [![Version](https://img.shields.io/github/v/tag/action-pack/gitlab-sync?label=version&sort=semver&color=066da5)](https://github.com/marketplace/actions/gitlab-sync) 6 | [![Size](https://img.shields.io/github/languages/code-size/action-pack/gitlab-sync?label=size&color=066da5)](https://github.com/action-pack/gitlab-sync/) 7 | 8 |

9 | 10 | Action to mirror a repository to GitLab. 11 | 12 | ## Usage 🚀 13 | 14 | ```yaml 15 | name: Gitlab Sync 16 | 17 | on: [push, pull_request, create, delete] 18 | 19 | jobs: 20 | sync: 21 | name: Gitlab Sync 22 | runs-on: ubuntu-latest 23 | steps: 24 | - uses: actions/checkout@v4 25 | with: 26 | fetch-depth: 0 27 | - uses: action-pack/gitlab-sync@v3 28 | with: 29 | username: ${{ github.actor }} 30 | url: https://gitlab.com/${{ github.repository }}.git 31 | # Personal access token from gitlab.com 32 | token: ${{ secrets.GITLAB_TOKEN }} 33 | ``` 34 | 35 | ## Stars 🌟 36 | [![Stars](https://starchart.cc/action-pack/gitlab-sync.svg?variant=adaptive)](https://starchart.cc/action-pack/gitlab-sync) 37 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Build 2 | 3 | on: 4 | workflow_dispatch: 5 | 6 | concurrency: 7 | group: build 8 | cancel-in-progress: false 9 | 10 | jobs: 11 | shellcheck: 12 | name: Check 13 | uses: ./.github/workflows/check.yml 14 | 15 | release: 16 | name: Release 17 | runs-on: ubuntu-latest 18 | needs: shellcheck 19 | permissions: 20 | contents: write 21 | steps: 22 | - uses: actions/checkout@v5 23 | with: 24 | fetch-depth: 0 25 | - name: Selfcheck 26 | uses: action-pack/gitlab-sync@master 27 | with: 28 | url: ${{ secrets.GITLAB_URL }} 29 | token: ${{ secrets.GITLAB_TOKEN }} 30 | username: ${{ secrets.GITLAB_USERNAME }} 31 | - 32 | name: Get previous tag 33 | id: previousTag 34 | run: | 35 | name=$(git --no-pager tag --sort=creatordate --merged ${{ github.ref_name }} | tail -1) 36 | echo "previousTag: $name" 37 | echo "previousTag=$name" >> $GITHUB_ENV 38 | - 39 | name: Generate changelog 40 | id: changelog 41 | uses: requarks/changelog-action@v1 42 | with: 43 | token: ${{ github.token }} 44 | fromTag: ${{ github.ref_name }} 45 | toTag: ${{ env.previousTag }} 46 | writeToFile: false 47 | reverseOrder: true 48 | includeInvalidCommits: true 49 | excludeTypes: "docs,build,chore" 50 | - 51 | name: Create a release 52 | uses: action-pack/github-release@v2 53 | with: 54 | tag: "v${{ vars.MAJOR }}.${{ vars.MINOR }}" 55 | title: "v${{ vars.MAJOR }}.${{ vars.MINOR }}" 56 | token: ${{ secrets.REPO_ACCESS_TOKEN }} 57 | body: | 58 | ${{ steps.changelog.outputs.changes }} 59 | 60 | **Full Changelog**: https://github.com/${{ github.repository }}/compare//${{ env.previousTag }}...v${{ vars.MAJOR }}.${{ vars.MINOR }} 61 | - 62 | name: Update major release 63 | uses: action-pack/github-release@v2 64 | with: 65 | tag: "v${{ vars.MAJOR }}" 66 | title: "v${{ vars.MAJOR }}" 67 | token: ${{ secrets.REPO_ACCESS_TOKEN }} 68 | body: | 69 | ${{ steps.changelog.outputs.changes }} 70 | 71 | **Full Changelog**: https://github.com/${{ github.repository }}/compare//${{ env.previousTag }}...v${{ vars.MAJOR }}.${{ vars.MINOR }} 72 | - 73 | name: Increment version variable 74 | uses: action-pack/bump@v2 75 | with: 76 | token: ${{ secrets.REPO_ACCESS_TOKEN }} 77 | - 78 | name: Send mail 79 | uses: action-pack/send-mail@v1 80 | with: 81 | to: ${{secrets.MAILTO}} 82 | from: Github Actions <${{secrets.MAILTO}}> 83 | connection_url: ${{secrets.MAIL_CONNECTION}} 84 | subject: Build of ${{ github.event.repository.name }} v${{ vars.MAJOR }}.${{ vars.MINOR }} completed 85 | body: | 86 | The build job of ${{ github.event.repository.name }} v${{ vars.MAJOR }}.${{ vars.MINOR }} was completed successfully! 87 | 88 | See https://github.com/${{ github.repository }}/actions for more information. 89 | --------------------------------------------------------------------------------