diff --git a/.github/workflows/gitlab_sync_pr_issues.yml b/.github/workflows/gitlab_sync_pr_issues.yml index 29afd86e8..2bac5d759 100644 --- a/.github/workflows/gitlab_sync_pr_issues.yml +++ b/.github/workflows/gitlab_sync_pr_issues.yml @@ -1,17 +1,29 @@ name: Sync PRs and Issues to GitLab on: + push: + branches: + - '*' + pull_request: schedule: - cron: '0 * * * *' # Runs every hour workflow_dispatch: jobs: - sync: + Sync: runs-on: ubuntu-latest - + env: + GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_REPO: ${{ github.repository }} + GITLAB_REPO_1: 'SaintAngeLs/distributed_minispace' + GITLAB_REPO_2: 'distributed-asp-net-core-blazor-social-app/distributed_minispace' steps: - - name: Checkout repository + - name: Checkout code uses: actions/checkout@v2 + with: + submodules: true + fetch-depth: 0 # Fetch all branches - name: Set up Python uses: actions/setup-python@v2 @@ -23,12 +35,38 @@ jobs: python -m pip install --upgrade pip pip install requests + - name: Configuring git + run: | + git config --global user.email "voznesenskijandrej5@gmail.com" + git config --global user.name "Andrii Voznesenskyi" + + - name: Remove .gitlab-ci.yml for specific repository + run: | + if [[ "${{ github.repository }}" == "SaintAngeLs/distributed_minispace" ]]; then + rm -f .gitlab-ci.yml + fi + + - name: Adding GitLab remote repository 1 + run: | + GITLAB_REPO="https://oauth2:${{ secrets.GITLAB_TOKEN }}@gitlab.com/SaintAngeLs/distributed_minispace.git" + git remote add gitlab1 $GITLAB_REPO || git remote set-url gitlab1 $GITLAB_REPO + + - name: Adding GitLab remote repository 2 + run: | + GITLAB_REPO="https://oauth2:${{ secrets.GITLAB_TOKEN }}@gitlab.com/distributed-asp-net-core-blazor-social-app/distributed_minispace.git" + git remote add gitlab2 $GITLAB_REPO || git remote set-url gitlab2 $GITLAB_REPO + + - name: Push all branches and tags to both GitLab repositories + run: | + git push gitlab1 --all --tags --force + git push gitlab2 --all --tags --force + - name: Sync Pull Requests and Issues to GitLab env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN }} GITHUB_REPO: ${{ github.repository }} GITLAB_REPO_1: 'SaintAngeLs/distributed_minispace' - GITLAB_REPO_2: 'distributed-asp-net-core-blazor-social-app/distributed-asp-net-core-blazor-social-application/distributed-minispace' + GITLAB_REPO_2: 'distributed-asp-net-core-blazor-social-app/distributed_minispace' run: | - python sync_prs_issues.py + python .github/workflows/sync_prs_issues.py \ No newline at end of file