Skip to content

Resolve merge conflict for tag 0.302.0.0#24

Merged
jeffborg merged 115 commits intotag-0.302.0from
master
Mar 5, 2026
Merged

Resolve merge conflict for tag 0.302.0.0#24
jeffborg merged 115 commits intotag-0.302.0from
master

Conversation

@github-actions
Copy link

@github-actions github-actions bot commented Mar 5, 2026

A merge conflict was detected while syncing tag 0.302.0.0. Please resolve the conflict in this PR.

Comment on lines +11 to +61
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest

steps:
- name: Checkout the repository
uses: actions/checkout@v3
with:
fetch-depth: 0 # Fetch all branches and tags
token: ${{ secrets.EVCC_PAT }}

- name: Set up Git
run: |
git config user.name "GitHub Actions"
git config user.email "actions@github.com"

- name: Get merged branch name
id: get-branch
run: echo "BRANCH=${{ github.event.pull_request.base.ref }}" >> $GITHUB_ENV

- name: Validate branch name
id: validate-branch
run: |
# Extract the tag name from the branch name
TAG_NAME=$(echo "${{ env.BRANCH }}" | sed 's/tag-//')

# Check if the tag name matches the expected pattern
if [[ ! "$TAG_NAME" =~ ^0\.[0-9]+\.[0-9]+$ ]]; then
echo "Branch name does not match the expected pattern. Skipping tag creation."
exit 1
else
echo "Valid branch name: $TAG_NAME Saving for next step"
echo "BRANCH=$TAG_NAME" >> $GITHUB_OUTPUT
fi
continue-on-error: true

- name: Tag the merged branch
if: success() && steps.validate-branch.outcome == 'success'
run: |
# Checkout the branch that was merged
git checkout "${{ env.BRANCH }}"

# Create the new tag
NEW_TAG="${{ steps.validate-branch.outputs.BRANCH }}.0"

# Tag the branch
git tag "${NEW_TAG}"

# Push the tag to the repository
git push origin "${NEW_TAG}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI 5 months ago

To fix the problem, the workflow should declare an explicit permissions: block at either the workflow or job level. The block should grant the minimum necessary permissions for the required operations. For this workflow, it needs to push tags, which requires contents: write. Unless other write scopes (e.g., pull-requests: write, issues: write) are needed, they can be omitted.

The best fix is to add permissions: at the job level (finalize:) as this targets only the job requiring the permission, avoiding possible future excess permissions for other jobs. Insert under jobs: finalize: (above if:) the following block:

permissions:
  contents: write

This makes the required permission explicit and limited. No changes to steps, imports, or other files are necessary.


Suggested changeset 1
.github/workflows/sync-tags-pr.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/sync-tags-pr.yml b/.github/workflows/sync-tags-pr.yml
--- a/.github/workflows/sync-tags-pr.yml
+++ b/.github/workflows/sync-tags-pr.yml
@@ -8,6 +8,8 @@
 
 jobs:
   finalize:
+    permissions:
+      contents: write
     if: github.event.pull_request.merged == true
     runs-on: ubuntu-latest
 
EOF
@@ -8,6 +8,8 @@

jobs:
finalize:
permissions:
contents: write
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest

Copilot is powered by AI and may make mistakes. Always verify output.
Comment on lines +11 to +98
runs-on: ubuntu-latest

steps:
- name: Checkout the repository
uses: actions/checkout@v3
with:
fetch-depth: 0 # Fetch all branches and tags
token: ${{ secrets.EVCC_PAT }}

- name: Set up Git
run: |
git config user.name "GitHub Actions"
git config user.email "actions@github.com"

- name: Add public repo as remote
run: |
git remote add public https://github.com/evcc-io/evcc.git

- name: Fetch tags from the public repo
run: |
git fetch public --tags

- name: Get all tags from the public repo
id: get-public-tags
run: |
git tag -l | grep -E '^0\.[0-9]+\.[0-9]+$' > public_tags.txt
echo "Public tags:"
cat public_tags.txt

- name: Get existing tags in the repo
id: get-existing-tags
run: |
git tag -l | grep -E '^0\.[0-9]+\.[0-9]+\.0$' > existing_tags.txt
echo "Existing tags:"
cat existing_tags.txt

- name: Sync missing tags
run: |
# Define the starting tag
START_TAG="0.130.7"

# Convert version to numeric format for comparison
tag_to_numeric() {
echo "$1" | sed 's/\./_/g' | awk -F'_' '{ printf("%d%03d%03d", $1, $2, $3) }'
}

START_NUMERIC=$(tag_to_numeric $START_TAG)

# Read tags from files
PUBLIC_TAGS=$(cat public_tags.txt)
EXISTING_TAGS=$(cat existing_tags.txt)

for TAG in $PUBLIC_TAGS; do
# Convert the current tag to numeric format
TAG_NUMERIC=$(tag_to_numeric $TAG)

# Check if the tag is greater than the starting tag
if [ "$TAG_NUMERIC" -gt "$START_NUMERIC" ]; then
# Generate the new tag name with .0 suffix
NEW_TAG="${TAG}.0"

# Check if the tag already exists
if ! echo "$EXISTING_TAGS" | grep -q "^${NEW_TAG}$"; then
echo "Processing new tag: $NEW_TAG"

# Create a new branch for the tag
git checkout -b "tag-${TAG}" ${TAG}

# Attempt to merge the master branch into the new branch
git merge master --no-edit || {
# If there's a merge conflict, create a pull request
echo "Merge conflict detected for tag ${TAG}. Creating pull request."
git push origin "tag-${TAG}"
gh pr create --title "Resolve merge conflict for tag ${NEW_TAG}" --body "A merge conflict was detected while syncing tag ${NEW_TAG}. Please resolve the conflict in this PR." --head master --base "tag-${TAG}"
continue
}
# Tag the branch with .0 appended to the original tag name
git tag "${NEW_TAG}"

# Push the new branch and tag to your repository
git push origin "tag-${TAG}"
git push origin "${NEW_TAG}"
fi
fi
done

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI 5 months ago

To resolve the problem, add a permissions block at the job or workflow root (above or at the same level as runs-on for the job), specifying only the minimal required permissions needed. Given the workflow pushes tags and branches (git push) and creates pull requests via the gh CLI (gh pr create), it requires contents: write (for pushing content) and pull-requests: write (for creating PRs). The permissions block should be added to the sync job in .github/workflows/sync-tags.yml, immediately before runs-on: ubuntu-latest. No additional methods or imports are required.

Suggested changeset 1
.github/workflows/sync-tags.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/sync-tags.yml b/.github/workflows/sync-tags.yml
--- a/.github/workflows/sync-tags.yml
+++ b/.github/workflows/sync-tags.yml
@@ -8,6 +8,9 @@
 
 jobs:
   sync:
+    permissions:
+      contents: write
+      pull-requests: write
     runs-on: ubuntu-latest
 
     steps:
EOF
@@ -8,6 +8,9 @@

jobs:
sync:
permissions:
contents: write
pull-requests: write
runs-on: ubuntu-latest

steps:
Copilot is powered by AI and may make mistakes. Always verify output.
Comment on lines +11 to +44
runs-on: ubuntu-latest

steps:
- name: Checkout the repository
uses: actions/checkout@v3
with:
# Fetch all branches
fetch-depth: 0
token: ${{ secrets.EVCC_PAT }}

- name: Set up Git
run: |
git config user.name "GitHub Actions"
git config user.email "actions@github.com"

- name: Add public repo as remote
run: |
git remote add public https://github.com/evcc-io/evcc.git

- name: Fetch master branch from public repo
run: |
git fetch public master

- name: Checkout evcc-master branch
run: |
git checkout evcc-master

- name: Merge master branch from public repo into evcc-master
run: |
git merge public/master --no-edit

- name: Push changes to evcc-master
run: |
git push origin evcc-master

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI 5 months ago

The best way to fix the problem is to add an explicit permissions block to the workflow, scoping the available permissions to the least amount necessary. Since this workflow only syncs branches and does not directly interact with issues, PRs, or perform any artifact uploads, the minimal required permission is likely just contents: read. Add the following under the top-level keys (name/on and before jobs:) in .github/workflows/sync-upstream.yml:

permissions:
  contents: read

This limits the GITHUB_TOKEN to only read repository contents. If any future steps require additional permissions, those can be enabled on a per-job or per-step basis.


Suggested changeset 1
.github/workflows/sync-upstream.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/sync-upstream.yml b/.github/workflows/sync-upstream.yml
--- a/.github/workflows/sync-upstream.yml
+++ b/.github/workflows/sync-upstream.yml
@@ -6,6 +6,9 @@
     - cron: "0 20 * * *"
   workflow_dispatch: # Allows manual trigger of the workflow
 
+permissions:
+  contents: read
+
 jobs:
   sync:
     runs-on: ubuntu-latest
EOF
@@ -6,6 +6,9 @@
- cron: "0 20 * * *"
workflow_dispatch: # Allows manual trigger of the workflow

permissions:
contents: read

jobs:
sync:
runs-on: ubuntu-latest
Copilot is powered by AI and may make mistakes. Always verify output.
@jeffborg jeffborg merged commit ba4c785 into tag-0.302.0 Mar 5, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants