From abcdab93f3fdf0a93c9b908f8a69fda42701d94b Mon Sep 17 00:00:00 2001 From: fantonangeli Date: Fri, 12 Apr 2024 17:58:24 +0200 Subject: [PATCH 1/7] Add upstream-sync workflow --- .ci/actions/upstream-sync/action.yml | 47 ++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 .ci/actions/upstream-sync/action.yml diff --git a/.ci/actions/upstream-sync/action.yml b/.ci/actions/upstream-sync/action.yml new file mode 100644 index 00000000..ab7383fe --- /dev/null +++ b/.ci/actions/upstream-sync/action.yml @@ -0,0 +1,47 @@ +name: Sync main-apache branch with upstream/main + +inputs: + username: + description: 'Git username' + required: true + useremail: + description: 'Git user email' + required: true + upstream_remote: + description: 'URL of the upstream remote repository' + required: true + github_token: + description: 'GitHub token for authentication' + required: true + +runs: + using: 'composite' + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + token: ${{ inputs.github_token }} + + - name: Setup git environment + run: | + git config --global user.name "${{ inputs.username }}" + git config --global user.email "${{ inputs.useremail }}" + git remote add upstream ${{ inputs.upstream_remote }} + + - name: Fetch all + run: git fetch --all --tags + + - name: Checkout main-apache branch + run: git checkout --track origin/main-apache + + - name: Pull main-apache branch + run: git pull + + - name: Merge upstream/main branch + run: git merge --no-edit upstream/main + + - name: Push changes + run: git push + + - name: Push last tag + run: git push origin $(git tag --sort=creatordate | tail -n 1) From 3d31bd0cdfa7f11bbee25c236e0091cf266a694e Mon Sep 17 00:00:00 2001 From: fantonangeli Date: Wed, 17 Apr 2024 18:14:23 +0200 Subject: [PATCH 2/7] Updated workflow --- .ci/actions/upstream-sync/action.yml | 40 ++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/.ci/actions/upstream-sync/action.yml b/.ci/actions/upstream-sync/action.yml index ab7383fe..cdd45845 100644 --- a/.ci/actions/upstream-sync/action.yml +++ b/.ci/actions/upstream-sync/action.yml @@ -1,47 +1,65 @@ -name: Sync main-apache branch with upstream/main +name: 'Sync main-apache branch' +description: 'Sync main-apache branch with upstream/main' inputs: username: - description: 'Git username' - required: true + description: 'Username for git' + required: false + default: kie-ci useremail: - description: 'Git user email' - required: true + description: 'User email for git' + required: false + default: kie-ci0@redhat.com upstream_remote: description: 'URL of the upstream remote repository' required: true - github_token: - description: 'GitHub token for authentication' - required: true + dry_run: + description: 'True to perform a dry run (dry run git push and skip create PR step)' + required: false + default: false runs: + # TODO: uncomment + # if: github.repository_owner == 'kiegroup' using: 'composite' steps: - name: Checkout repository uses: actions/checkout@v4 with: - token: ${{ inputs.github_token }} + token: $GITHUB_TOKEN - name: Setup git environment + shell: bash run: | + set -x git config --global user.name "${{ inputs.username }}" git config --global user.email "${{ inputs.useremail }}" git remote add upstream ${{ inputs.upstream_remote }} - name: Fetch all + shell: bash run: git fetch --all --tags - name: Checkout main-apache branch + shell: bash run: git checkout --track origin/main-apache - name: Pull main-apache branch + shell: bash run: git pull - name: Merge upstream/main branch + shell: bash run: git merge --no-edit upstream/main - name: Push changes - run: git push + shell: bash + run: | + set -x + git push${{ inputs.dry_run == 'true' && ' --dry-run' || '' }} - name: Push last tag - run: git push origin $(git tag --sort=creatordate | tail -n 1) + shell: bash + run: | + set -x + git push origin $(git tag --sort=creatordate | tail -n 1)${{ inputs.dry_run == 'true' && ' --dry-run' || '' }} From 1d860247a840f1195ceac71411d4da898ebde2e6 Mon Sep 17 00:00:00 2001 From: fantonangeli Date: Mon, 22 Apr 2024 11:46:31 +0200 Subject: [PATCH 3/7] Fix err "not a git repository" testing with act --- .ci/actions/upstream-sync/action.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.ci/actions/upstream-sync/action.yml b/.ci/actions/upstream-sync/action.yml index cdd45845..47522b81 100644 --- a/.ci/actions/upstream-sync/action.yml +++ b/.ci/actions/upstream-sync/action.yml @@ -27,6 +27,7 @@ runs: uses: actions/checkout@v4 with: token: $GITHUB_TOKEN + ref: main - name: Setup git environment shell: bash From 30369c09c8a926b4b5812b55443c37bf85ec47d5 Mon Sep 17 00:00:00 2001 From: fantonangeli Date: Mon, 22 Apr 2024 12:09:03 +0200 Subject: [PATCH 4/7] Fixed tab space --- .ci/actions/upstream-sync/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ci/actions/upstream-sync/action.yml b/.ci/actions/upstream-sync/action.yml index 47522b81..6cbe82a6 100644 --- a/.ci/actions/upstream-sync/action.yml +++ b/.ci/actions/upstream-sync/action.yml @@ -32,7 +32,7 @@ runs: - name: Setup git environment shell: bash run: | - set -x + set -x git config --global user.name "${{ inputs.username }}" git config --global user.email "${{ inputs.useremail }}" git remote add upstream ${{ inputs.upstream_remote }} From 694da64097451de5d19614b9049ed1737ea3596a Mon Sep 17 00:00:00 2001 From: fantonangeli Date: Mon, 22 Apr 2024 12:12:31 +0200 Subject: [PATCH 5/7] Fix tab --- .ci/actions/upstream-sync/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ci/actions/upstream-sync/action.yml b/.ci/actions/upstream-sync/action.yml index 6cbe82a6..a3f91e4f 100644 --- a/.ci/actions/upstream-sync/action.yml +++ b/.ci/actions/upstream-sync/action.yml @@ -32,7 +32,7 @@ runs: - name: Setup git environment shell: bash run: | - set -x + set -x git config --global user.name "${{ inputs.username }}" git config --global user.email "${{ inputs.useremail }}" git remote add upstream ${{ inputs.upstream_remote }} From 37158fe307eda9101f661b9045ed914ffd6d33c9 Mon Sep 17 00:00:00 2001 From: fantonangeli Date: Mon, 22 Apr 2024 15:59:53 +0200 Subject: [PATCH 6/7] Trying without the token as param to actions/checkout --- .ci/actions/upstream-sync/action.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.ci/actions/upstream-sync/action.yml b/.ci/actions/upstream-sync/action.yml index a3f91e4f..c48e04d4 100644 --- a/.ci/actions/upstream-sync/action.yml +++ b/.ci/actions/upstream-sync/action.yml @@ -26,7 +26,6 @@ runs: - name: Checkout repository uses: actions/checkout@v4 with: - token: $GITHUB_TOKEN ref: main - name: Setup git environment From f76b05cd905de73ff627917f8772e64acf799045 Mon Sep 17 00:00:00 2001 From: fantonangeli Date: Mon, 29 Apr 2024 11:29:54 +0200 Subject: [PATCH 7/7] Uncomment owner check --- .ci/actions/upstream-sync/action.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.ci/actions/upstream-sync/action.yml b/.ci/actions/upstream-sync/action.yml index c48e04d4..67f66155 100644 --- a/.ci/actions/upstream-sync/action.yml +++ b/.ci/actions/upstream-sync/action.yml @@ -19,8 +19,7 @@ inputs: default: false runs: - # TODO: uncomment - # if: github.repository_owner == 'kiegroup' + if: github.repository_owner == 'kiegroup' using: 'composite' steps: - name: Checkout repository