From 5d061d0a8367374c1c877d79a341dd2f5afbc61f 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 | 53 ++++++++++++++++++++++++++++++++ 1 file changed, 53 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..b5ba5a8b2 --- /dev/null +++ b/.github/workflows/fork-sync.yaml @@ -0,0 +1,53 @@ +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: actions/checkout@v4 + if: ${{ matrix.branch != '' }} + with: + ref: ${{ matrix.branch }} + # fetch-depth: 10 + - name: Sync + if: ${{ matrix.branch != '' }} + env: + GH_TOKEN: ${{ secrets.GH_TOKEN_NVIDIA_CI_CD }} + run: | + git config user.name nvidia-ci-cd + git config user.email svc-cloud-orch-gh@nvidia.com + git remote add upstream https://github.com/k8snetworkplumbingwg/sriov-network-operator.git + + git status; git branch # debug + git checkout ${{ matrix.branch }} # TODO: see if redundant when working with `ref` in checkout step + git status; git branch # debug + git log --oneline -n 4 # debug + git pull upstream master + git log --oneline -n 10 # debug + + # git push --force origin HEAD # TODO: uncomment only after testing commands above +