diff --git a/.github/actions/rebase/action.yaml b/.github/actions/rebase/action.yaml new file mode 100644 index 000000000..0cf148fdf --- /dev/null +++ b/.github/actions/rebase/action.yaml @@ -0,0 +1,35 @@ +name: 'Rebase' +description: 'Action for rebasing to the main branch' + +runs: + using: 'composite' + steps: + + # Setup identity to avoid errors when git is trying to rebase without identity set + - name: Setup git identity + run: | + git config --global user.email "rebase@action.com" + git config --global user.name "Rebase Action" + shell: bash + + # Update origin/main branch locally to cover case when repo is not fully cloned + # for example when using `actions/checkout@v4` action with default `fetch-depth` value (1) + # read more: https://github.com/actions/checkout?tab=readme-ov-file#usage + - name: Update origin/main + run: | + git fetch origin main + git checkout --track origin/main + git pull --unshallow origin main + + git switch --detach - + shell: bash + + - name: Rebase to main + run: | + git rebase main + shell: bash + + - name: Print branch log + run: | + git log origin/main~1.. + shell: bash diff --git a/.github/workflows/gitleaks.yaml b/.github/workflows/gitleaks.yaml index 2b2575322..beeb7869c 100644 --- a/.github/workflows/gitleaks.yaml +++ b/.github/workflows/gitleaks.yaml @@ -11,8 +11,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - with: - fetch-depth: 0 + - uses: ./.github/actions/rebase - name: Fetch gitleaks ${{ env.GITLEAKS_VERSION }} run: curl -Lso gitleaks.tar.gz https://github.com/gitleaks/gitleaks/releases/download/v${{ env.GITLEAKS_VERSION }}/gitleaks_${{ env.GITLEAKS_VERSION }}_linux_x64.tar.gz && tar -xvzf ./gitleaks.tar.gz - name: Run gitleaks diff --git a/.github/workflows/integration-tests-pull.yaml b/.github/workflows/integration-tests-pull.yaml index 6a58463b3..62e5ae667 100644 --- a/.github/workflows/integration-tests-pull.yaml +++ b/.github/workflows/integration-tests-pull.yaml @@ -13,6 +13,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - uses: ./.github/actions/rebase - uses: ./.github/actions/setup-go - uses: ./.github/actions/create-single-cluster - name: run test @@ -28,6 +29,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - uses: ./.github/actions/rebase - uses: ./.github/actions/setup-go - uses: ./.github/actions/create-single-cluster - name: run test diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index d2cf060cb..758ab891d 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -13,6 +13,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - uses: ./.github/actions/rebase - uses: ./.github/actions/setup-go - uses: golangci/golangci-lint-action@v3 with: @@ -23,6 +24,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - uses: ./.github/actions/rebase - uses: ./.github/actions/setup-go - uses: ./.github/actions/setup-libgit2 - uses: golangci/golangci-lint-action@v3 diff --git a/.github/workflows/markdown.yaml b/.github/workflows/markdown.yaml index acee96c7f..56f2ed037 100644 --- a/.github/workflows/markdown.yaml +++ b/.github/workflows/markdown.yaml @@ -9,6 +9,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - uses: ./.github/actions/rebase - uses: gaurav-nelson/github-action-markdown-link-check@v1 with: use-quiet-mode: 'yes' diff --git a/.github/workflows/unit-tests.yaml b/.github/workflows/unit-tests.yaml index 0a57af9cc..a11447af0 100644 --- a/.github/workflows/unit-tests.yaml +++ b/.github/workflows/unit-tests.yaml @@ -12,6 +12,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - uses: ./.github/actions/rebase - uses: ./.github/actions/setup-go - name: run test run: make -C components/operator test @@ -20,6 +21,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - uses: ./.github/actions/rebase - uses: ./.github/actions/setup-go - uses: ./.github/actions/setup-libgit2 - name: run test