From 92e47bc89ad7194e6788aa07c4de38f1b3bb5c55 Mon Sep 17 00:00:00 2001 From: EED85 Date: Sun, 20 Jul 2025 09:17:09 +0200 Subject: [PATCH 1/3] copilot changes [no ci] --- .../callable_update_eed_basic_utils.yml | 120 ++++++++++++++++++ .github/workflows/update_eed_basic_utils.yml | 118 +---------------- 2 files changed, 123 insertions(+), 115 deletions(-) create mode 100644 .github/workflows/callable_update_eed_basic_utils.yml diff --git a/.github/workflows/callable_update_eed_basic_utils.yml b/.github/workflows/callable_update_eed_basic_utils.yml new file mode 100644 index 0000000..1a5d118 --- /dev/null +++ b/.github/workflows/callable_update_eed_basic_utils.yml @@ -0,0 +1,120 @@ +name: callable_update_eed_basic_utils + +on: + workflow_call: + +jobs: + update-eed-basic-utils: + runs-on: ubuntu-latest + steps: + - name: Get triggering user login + id: get_user + run: | + trigger_user="${{ github.triggering_actor }}" + echo "trigger_user=$trigger_user" >> $GITHUB_OUTPUT + echo "Workflow triggered by: trigger_user" + - name: Get base branch name + id: get_base_branch + run: | + base_branch=${GITHUB_REF_NAME} + echo "base_branch=$base_branch" >> $GITHUB_OUTPUT + echo "base_branch=$base_branch" + - name: Set package variable + id: define_package_name + run: | + package="eed_basic_utils" + echo "package=$package" >> $GITHUB_OUTPUT + echo "package=$package" + - name: Set branch variable + id: define_branch_name + run: | + branch="update_eed_packages" + echo "branch=$branch" >> $GITHUB_OUTPUT + echo "branch=$branch" + - name: Checkout repository + uses: actions/checkout@v4 + with: + token: ${{ secrets.GH_PAT }} + - name: Set up git user + run: | + git config --global user.name "github-actions[bot]" + git config --global user.email "github-actions[bot]@users.noreply.github.com" + - name: Fetch and list all branches + run: | + git fetch --all + git branch --list + - name: Check if branch exists + id: branch_check + run: | + branch="${{ steps.define_branch_name.outputs.branch }}" + if git ls-remote --heads origin $branch | grep -q $branch ; then + branch_exists=true + else + branch_exists=false + fi + echo "branch_exists=$branch_exists" >> $GITHUB_OUTPUT + echo "branch_exists=$branch_exists" + + - name: Checkout or create branch + run: | + branch="${{ steps.define_branch_name.outputs.branch }}" + if [ "${{ steps.branch_check.outputs.branch_exists }}" = "true" ]; then + git switch $branch && git pull + else + git switch -c $branch + fi + commit_id=$(git rev-parse HEAD) + echo "commit_id = $commit_id" + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version-file: .python-version + - name: Install dependencies + run: | + pip install uv + python -m pip install --upgrade pip + uv sync + - name: Update ${{ steps.define_package_name.outputs.package }} using uv + run: uv add "${{ steps.define_package_name.outputs.package }}" --upgrade-package "${{ steps.define_package_name.outputs.package }}" + + - name: Check for changes + id: changes + run: | + if git status --porcelain | grep .; then + echo "changed=true" >> $GITHUB_OUTPUT + else + echo "changed=false" >> $GITHUB_OUTPUT + fi + + - name: Commit and push changes + if: steps.changes.outputs.changed == 'true' + run: | + branch="${{ steps.define_branch_name.outputs.branch }}" + git add . + git commit -m "Update ${{ steps.define_package_name.outputs.package }}" + git push origin $branch + + - name: Check for existing open PR + id: pr_check + env: + GH_TOKEN: ${{ secrets.GH_PAT }} + run: | + branch="${{ steps.define_branch_name.outputs.branch }}" + pr_number=$(gh pr list --head "$branch" --state open --json number --jq '.[0].number') + if [ -n "$pr_number" ]; then + pr_exists=true + else + pr_exists=false + fi + echo "pr_exists=$pr_exists" >> $GITHUB_OUTPUT + echo "pr_exists=$pr_exists" + - name: create pull request + if: steps.changes.outputs.changed == 'true' && steps.pr_check.outputs.pr_exists == 'false' + env: + GH_TOKEN: ${{ secrets.GH_PAT }} + run: | + base_branch="${{ steps.get_base_branch.outputs.base_branch }}" + pr_title="${{ steps.define_branch_name.outputs.branch }}" + user="${{ steps.get_user.outputs.trigger_user }}" + pr_url=$(gh pr create --title "$pr_title" --body "$pr_title" --base "$base_branch" --assignee "$user" --reviewer "$user") + echo "Created PR: $pr_url" \ No newline at end of file diff --git a/.github/workflows/update_eed_basic_utils.yml b/.github/workflows/update_eed_basic_utils.yml index 075ef84..b84b70e 100644 --- a/.github/workflows/update_eed_basic_utils.yml +++ b/.github/workflows/update_eed_basic_utils.yml @@ -1,120 +1,8 @@ -name: Update eed_basic_utils +name: update_eed_basic_utils_caller on: workflow_dispatch: jobs: - update-eed-basic-utils: - runs-on: ubuntu-latest - steps: - - name: Get triggering user login - id: get_user - run: | - trigger_user="${{ github.triggering_actor }}" - echo "trigger_user=$trigger_user" >> $GITHUB_OUTPUT - echo "Workflow triggered by: trigger_user" - - name: Get base branch name - id: get_base_branch - run: | - base_branch=${GITHUB_REF_NAME} - echo "base_branch=$base_branch" >> $GITHUB_OUTPUT - echo "base_branch=$base_branch" - - name: Set package variable - id: define_package_name - run: | - package="eed_basic_utils" - echo "package=$package" >> $GITHUB_OUTPUT - echo "package=$package" - - name: Set branch variable - id: define_branch_name - run: | - branch="update_eed_packages" - echo "branch=$branch" >> $GITHUB_OUTPUT - echo "branch=$branch" - - name: Checkout repository - uses: actions/checkout@v4 - with: - token: ${{ secrets.GH_PAT }} - - name: Set up git user - run: | - git config --global user.name "github-actions[bot]" - git config --global user.email "github-actions[bot]@users.noreply.github.com" - - name: Fetch and list all branches - run: | - git fetch --all - git branch --list - - name: Check if branch exists - id: branch_check - run: | - branch="${{ steps.define_branch_name.outputs.branch }}" - if git ls-remote --heads origin $branch | grep -q $branch ; then - branch_exists=true - else - branch_exists=false - fi - echo "branch_exists=$branch_exists" >> $GITHUB_OUTPUT - echo "branch_exists=$branch_exists" - - - name: Checkout or create branch - run: | - branch="${{ steps.define_branch_name.outputs.branch }}" - if [ "${{ steps.branch_check.outputs.branch_exists }}" = "true" ]; then - git switch $branch && git pull - else - git switch -c $branch - fi - commit_id=$(git rev-parse HEAD) - echo "commit_id = $commit_id" - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version-file: .python-version - - name: Install dependencies - run: | - pip install uv - python -m pip install --upgrade pip - uv sync - - name: Update ${{ steps.define_package_name.outputs.package }} using uv - run: uv add "${{ steps.define_package_name.outputs.package }}" --upgrade-package "${{ steps.define_package_name.outputs.package }}" - - - name: Check for changes - id: changes - run: | - if git status --porcelain | grep .; then - echo "changed=true" >> $GITHUB_OUTPUT - else - echo "changed=false" >> $GITHUB_OUTPUT - fi - - - name: Commit and push changes - if: steps.changes.outputs.changed == 'true' - run: | - branch="${{ steps.define_branch_name.outputs.branch }}" - git add . - git commit -m "Update ${{ steps.define_package_name.outputs.package }}" - git push origin $branch - - - name: Check for existing open PR - id: pr_check - env: - GH_TOKEN: ${{ secrets.GH_PAT }} - run: | - branch="${{ steps.define_branch_name.outputs.branch }}" - pr_number=$(gh pr list --head "$branch" --state open --json number --jq '.[0].number') - if [ -n "$pr_number" ]; then - pr_exists=true - else - pr_exists=false - fi - echo "pr_exists=$pr_exists" >> $GITHUB_OUTPUT - echo "pr_exists=$pr_exists" - - name: create pull request - if: steps.changes.outputs.changed == 'true' && steps.pr_check.outputs.pr_exists == 'false' - env: - GH_TOKEN: ${{ secrets.GH_PAT }} - run: | - base_branch="${{ steps.get_base_branch.outputs.base_branch }}" - pr_title="${{ steps.define_branch_name.outputs.branch }}" - user="${{ steps.get_user.outputs.trigger_user }}" - pr_url=$(gh pr create --title "$pr_title" --body "$pr_title" --base "$base_branch" --assignee "$user" --reviewer "$user") - echo "Created PR: $pr_url" + call-update-eed-basic-utils: + uses: ./.github/workflows/callable_update_eed_basic_utils.yml From 978c169c28f33c111636ba4d1b6a0ef514f53926 Mon Sep 17 00:00:00 2001 From: EED85 Date: Sun, 20 Jul 2025 09:20:36 +0200 Subject: [PATCH 2/3] add input for package name --- .github/workflows/callable_update_eed_basic_utils.yml | 8 ++++++-- .github/workflows/update_eed_basic_utils.yml | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/callable_update_eed_basic_utils.yml b/.github/workflows/callable_update_eed_basic_utils.yml index 1a5d118..265e563 100644 --- a/.github/workflows/callable_update_eed_basic_utils.yml +++ b/.github/workflows/callable_update_eed_basic_utils.yml @@ -2,6 +2,10 @@ name: callable_update_eed_basic_utils on: workflow_call: + inputs: + package_name: + required: true + type: string jobs: update-eed-basic-utils: @@ -22,7 +26,7 @@ jobs: - name: Set package variable id: define_package_name run: | - package="eed_basic_utils" + package="${{ inputs.package_name }}" echo "package=$package" >> $GITHUB_OUTPUT echo "package=$package" - name: Set branch variable @@ -117,4 +121,4 @@ jobs: pr_title="${{ steps.define_branch_name.outputs.branch }}" user="${{ steps.get_user.outputs.trigger_user }}" pr_url=$(gh pr create --title "$pr_title" --body "$pr_title" --base "$base_branch" --assignee "$user" --reviewer "$user") - echo "Created PR: $pr_url" \ No newline at end of file + echo "Created PR: $pr_url" diff --git a/.github/workflows/update_eed_basic_utils.yml b/.github/workflows/update_eed_basic_utils.yml index b84b70e..5de9776 100644 --- a/.github/workflows/update_eed_basic_utils.yml +++ b/.github/workflows/update_eed_basic_utils.yml @@ -6,3 +6,5 @@ on: jobs: call-update-eed-basic-utils: uses: ./.github/workflows/callable_update_eed_basic_utils.yml + with: + package_name: eed_basic_utils From 91dba7af086eb9d659285e77bcd1400cc39d5e65 Mon Sep 17 00:00:00 2001 From: EED85 Date: Sun, 20 Jul 2025 09:23:46 +0200 Subject: [PATCH 3/3] pass secrets [no ci] --- .github/workflows/update_eed_basic_utils.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/update_eed_basic_utils.yml b/.github/workflows/update_eed_basic_utils.yml index 5de9776..957ad97 100644 --- a/.github/workflows/update_eed_basic_utils.yml +++ b/.github/workflows/update_eed_basic_utils.yml @@ -1,4 +1,4 @@ -name: update_eed_basic_utils_caller +name: update_eed_basic_utils on: workflow_dispatch: @@ -8,3 +8,5 @@ jobs: uses: ./.github/workflows/callable_update_eed_basic_utils.yml with: package_name: eed_basic_utils + secrets: + GH_PAT: ${{ secrets.GH_PAT }}