From 01c6564323d5fe4a159abc2b5ba9d1e78e6a5612 Mon Sep 17 00:00:00 2001 From: Filip Strozik Date: Wed, 8 May 2024 08:45:13 +0200 Subject: [PATCH 1/5] create rebase action --- .github/actions/rebase/action.yaml | 25 +++++++++++++++++++ .github/workflows/gitleaks.yaml | 3 +-- .github/workflows/integration-tests-pull.yaml | 2 ++ .github/workflows/lint.yaml | 2 ++ .github/workflows/markdown.yaml | 1 + .github/workflows/unit-tests.yaml | 2 ++ 6 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 .github/actions/rebase/action.yaml diff --git a/.github/actions/rebase/action.yaml b/.github/actions/rebase/action.yaml new file mode 100644 index 000000000..1076657be --- /dev/null +++ b/.github/actions/rebase/action.yaml @@ -0,0 +1,25 @@ +name: 'Rebase' +description: 'Action for rebasing to the main branch' + +runs: + using: 'composite' + steps: + + - 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 From 325e559dd87b894d01643093f955ec028c6b775d Mon Sep 17 00:00:00 2001 From: Filip Strozik Date: Thu, 9 May 2024 13:27:32 +0200 Subject: [PATCH 2/5] setup action git identity --- .github/actions/rebase/action.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/actions/rebase/action.yaml b/.github/actions/rebase/action.yaml index 1076657be..8159a900d 100644 --- a/.github/actions/rebase/action.yaml +++ b/.github/actions/rebase/action.yaml @@ -5,6 +5,12 @@ runs: using: 'composite' steps: + - name: Setup git identity + run: | + git config --global user.email "rebase@action.com" + git config --global user.name "Rebase Action" + shell: bash + - name: Update origin/main run: | git fetch origin main From 51b0133cb9aedd79f8d722c217462055a5466a89 Mon Sep 17 00:00:00 2001 From: Filip Strozik Date: Thu, 9 May 2024 14:53:07 +0200 Subject: [PATCH 3/5] add action descriptions --- .github/actions/rebase/action.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/actions/rebase/action.yaml b/.github/actions/rebase/action.yaml index 8159a900d..4714ef858 100644 --- a/.github/actions/rebase/action.yaml +++ b/.github/actions/rebase/action.yaml @@ -5,12 +5,14 @@ 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 - name: Update origin/main run: | git fetch origin main From 92c518c7ea8d16a6107d4738aadcd85b78e7d6ab Mon Sep 17 00:00:00 2001 From: Filip Strozik Date: Thu, 9 May 2024 14:56:35 +0200 Subject: [PATCH 4/5] add action descriptions 2 --- .github/actions/rebase/action.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/actions/rebase/action.yaml b/.github/actions/rebase/action.yaml index 4714ef858..ea17d6f64 100644 --- a/.github/actions/rebase/action.yaml +++ b/.github/actions/rebase/action.yaml @@ -13,6 +13,8 @@ runs: 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 `fetch-depth` flag other than 0 + # read more: https://github.com/actions/checkout?tab=readme-ov-file#usage - name: Update origin/main run: | git fetch origin main From 7740b7e132e336c80a8b10c9ce5612dea10b6da3 Mon Sep 17 00:00:00 2001 From: Filip Strozik Date: Thu, 9 May 2024 15:12:18 +0200 Subject: [PATCH 5/5] add action descriptions 3 --- .github/actions/rebase/action.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/rebase/action.yaml b/.github/actions/rebase/action.yaml index ea17d6f64..0cf148fdf 100644 --- a/.github/actions/rebase/action.yaml +++ b/.github/actions/rebase/action.yaml @@ -13,7 +13,7 @@ runs: 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 `fetch-depth` flag other than 0 + # 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: |