forked from kujov/gitlab-sync
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
40 lines (40 loc) · 1.38 KB
/
action.yml
File metadata and controls
40 lines (40 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
name: 'Sync to GitLab'
description: 'Automatically sync your GitHub repository with GitLab'
branding:
icon: 'arrow-right'
color: 'orange'
inputs:
gitlab_url:
description: 'The URL of the GitLab repository (e.g., https://gitlab.com/user/repo.git)'
required: true
username:
description: 'Your GitLab username'
required: true
gitlab_pat:
description: 'Your GitLab Personal Access Token with required permissions'
required: true
force_push:
description: 'Whether to force push to GitLab. Defaults to false.'
required: false
default: 'false'
runs:
using: 'composite'
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Push to GitLab
run: |
export GIT_SSH_COMMAND='ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no'
gitlab_repo_url=${{ inputs.gitlab_url }}
gitlab_repo_url=${gitlab_repo_url#https://}
gitlab_repo_url_with_credentials="https://${{ inputs.username }}:${{ inputs.gitlab_pat }}@${gitlab_repo_url}"
git remote add gitlab "$gitlab_repo_url_with_credentials"
branch_name=$(echo $GITHUB_REF | sed 's/refs\/heads\///')
push_command="git push gitlab $branch_name"
if [[ "${{ inputs.force_push }}" == "true" ]]; then
push_command="$push_command --force"
fi
$push_command
shell: bash