fix auto mirror

This commit is contained in:
root
2025-10-03 05:26:42 +00:00
parent 7b8f64842a
commit e70c477238

View File

@@ -10,19 +10,41 @@ on:
types: [opened, edited, closed, reopened] types: [opened, edited, closed, reopened]
jobs: jobs:
# ---- Mirror CODE ----
mirror-code: mirror-code:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout repo - name: Checkout repo
uses: actions/checkout@v3 uses: actions/checkout@v3
- name: Push to GitLab - name: Setup Git
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
- name: Fetch GitLab branch
run: | run: |
git remote add gitlab https://oauth2:${{ secrets.GITLAB_TOKEN }}@gitlab.com/foxixus/neomovies_mobile.git git remote add gitlab https://oauth2:${{ secrets.GITLAB_TOKEN }}@gitlab.com/foxixus/neomovies_mobile.git
git push --mirror gitlab git fetch gitlab main || true
- name: Check for differences with GitLab
id: diffcheck
run: |
# Если нет ветки main на GitLab, пушим всегда
if ! git rev-parse gitlab/main >/dev/null 2>&1; then
echo "has_diff=true" >> $GITHUB_OUTPUT
else
DIFF=$(git rev-list --left-right --count HEAD...gitlab/main | awk '{print $1}')
if [[ "$DIFF" -gt 0 ]]; then
echo "has_diff=true" >> $GITHUB_OUTPUT
else
echo "has_diff=false" >> $GITHUB_OUTPUT
fi
fi
- name: Push to GitLab if there are changes
if: steps.diffcheck.outputs.has_diff == 'true'
run: git push gitlab HEAD:main
# ---- Mirror ISSUES ----
mirror-issues: mirror-issues:
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: github.event_name == 'issues' if: github.event_name == 'issues'
@@ -37,7 +59,6 @@ jobs:
\"description\": \"${{ github.event.issue.body }}\" \"description\": \"${{ github.event.issue.body }}\"
}" }"
# ---- Mirror PULL REQUESTS as MERGE REQUESTS ----
mirror-prs: mirror-prs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: github.event_name == 'pull_request' if: github.event_name == 'pull_request'