From b7b398d14140e63afc503b2b6e8ed8fbb36ce9b7 Mon Sep 17 00:00:00 2001 From: Michael Zeevi Date: Mon, 15 Jul 2024 14:18:53 +0300 Subject: [PATCH] feat: add github action to sync mellanox fork from k8swg upstream Signed-off-by: Michael Zeevi --- .github/workflows/fork-sync.yaml | 57 ++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 .github/workflows/fork-sync.yaml diff --git a/.github/workflows/fork-sync.yaml b/.github/workflows/fork-sync.yaml new file mode 100644 index 000000000..49eedf8c0 --- /dev/null +++ b/.github/workflows/fork-sync.yaml @@ -0,0 +1,57 @@ +name: Fork Sync + +on: + schedule: + - cron: '0 0 * * *' # nightly + workflow_dispatch: # enable manual trigger + +jobs: + lookup-most-recent-release-branch: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Lookup most recent release branch + id: lookup-most-recent-release-branch + run: | + git fetch --all + echo most_recent_release_branch=$(git branch --remotes --sort refname | grep network-operator- | tail -n 1 | cut -d '/' -f 2-) >> $GITHUB_OUTPUT + outputs: + most_recent_release_branch: ${{ steps.lookup-most-recent-release-branch.outputs.most_recent_release_branch }} + + sync-fork: + runs-on: ubuntu-latest + needs: lookup-most-recent-release-branch + strategy: + fail-fast: false + matrix: + branch: + - master + - ${{ needs.lookup-most-recent-release-branch.outputs.most_recent_release_branch }} + steps: + - uses: tgymnich/fork-sync@v2.0.10 + if: ${{ matrix.branch != '' }} + with: + owner: k8snetworkplumbingwg # upstream # TODO: revert to "k8snetworkplumbingwg" after troubleshooting + head: master # upstream + base: ${{ matrix.branch }} # downstream + pr_title: 'sync: from upstream master to ${{ matrix.branch }}' + pr_message: 'Created by [*${{ github.job }}* workflow job](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) to sync changes from [upstream](${{ github.server_url }}/k8snetworkplumbingwg/${{ github.event.repository.name }}) to [downstream](${{ github.server_url }}/${{ github.repository }}).' + retries: 1 + retry_after: 3 + token: ${{ secrets.GH_TOKEN_NVIDIA_CI_CD }} # fails to approve with niether nvidia-ci-cd or maze88 tokens... + # token: ${{ secrets.GITHUB_TOKEN }} # fails to approve with niether nvidia-ci-cd or maze88 tokens... + auto_approve: true + auto_merge: true + merge_method: rebase + # - uses: tgymnich/fork-sync@v1.3 # input `auto_approve` is broken in versions above 1.3 (https://github.com/tgymnich/fork-sync/issues/153#issuecomment-1868494745) and at least until 2.0.10 + # if: ${{ matrix.branch != '' }} + # with: + # owner: k8snetworkplumbingwg # upstream + # head: master # upstream + # base: ${{ matrix.branch }} # downstream + # github_token: ${{ secrets.GH_TOKEN_NVIDIA_CI_CD }} + # pr_title: 'sync: from upstream master to ${{ matrix.branch }}' + # pr_message: 'Created by [*${{ github.job }}* workflow job](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) to sync changes from [upstream](${{ github.server_url }}/k8snetworkplumbingwg/${{ github.event.repository.name }}) to [downstream](${{ github.server_url }}/${{ github.repository }}).' + # personal_token: ${{ secrets.GITHUB_TOKEN }} + # auto_approve: true + # merge_method: rebase