Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/gitflow-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ jobs:
const baseRef = pr.base.ref; // e.g. develop

const rules = [
// main to develop means merging main back into develop (git flow)
{ type: 'main', prefixes: ['main'], expectedBase: 'develop' },
{ type: 'feature', prefixes: ['feature/'], expectedBase: 'develop' },
{ type: 'bugfix', prefixes: ['bugfix/'], expectedBase: 'develop' },
{ type: 'chore', prefixes: ['chore/'], expectedBase: 'develop', botOnly: true },
Expand Down
28 changes: 17 additions & 11 deletions .github/workflows/gitflow.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
name: Upmerge main to develop (PR)

on:
workflow_run:
workflows:
- "Release"
types:
- completed
branches:
- main
push:
branches: [main]
workflow_dispatch: {}

concurrency:
Expand Down Expand Up @@ -46,13 +41,18 @@ jobs:
run: |
set -euo pipefail

git fetch origin "${SOURCE_BRANCH}:${SOURCE_BRANCH}" "${BASE_BRANCH}:${BASE_BRANCH}" || true
REPO="${GITHUB_REPOSITORY}"
OWNER="${REPO%%/*}"

# Fetch remote refs without writing into checked-out local branches
git fetch origin "+refs/heads/${SOURCE_BRANCH}:refs/remotes/origin/${SOURCE_BRANCH}" "+refs/heads/${BASE_BRANCH}:refs/remotes/origin/${BASE_BRANCH}"

TITLE="chore(gitflow): upmerge ${SOURCE_BRANCH} -> ${BASE_BRANCH}"
BODY=$'Automated upmerge PR.\n\nSource: `main`\nTarget: `develop`\nBranch: `feature/upmerge-main-to-develop`\n\nIf there are merge conflicts:\n1) Checkout `feature/upmerge-main-to-develop` locally\n2) Run `git fetch origin` then `git merge origin/develop`\n3) Resolve conflicts, commit, and push'

EXISTING_PR=$(gh pr list --state open --head "${HEAD_BRANCH}" --base "${BASE_BRANCH}" --json number --jq '.[0].number' || true)
# Find an existing open PR for HEAD_BRANCH -> BASE_BRANCH.
# Use GitHub API to avoid relying on gh CLI JSON flags that vary by version.
EXISTING_PR=$(gh api "repos/${REPO}/pulls?state=open&head=${OWNER}:${HEAD_BRANCH}&base=${BASE_BRANCH}" --jq '.[0].number' 2>/dev/null || true)

if [ -n "${EXISTING_PR}" ] && [ "${EXISTING_PR}" != "null" ]; then
echo "Found existing PR #${EXISTING_PR} for ${HEAD_BRANCH} -> ${BASE_BRANCH}"
Expand Down Expand Up @@ -87,6 +87,12 @@ jobs:
gh pr edit "${EXISTING_PR}" --title "${TITLE}" --body "${BODY}" >/dev/null
echo "Updated PR #${EXISTING_PR}"
else
PR_URL=$(gh pr create --head "${HEAD_BRANCH}" --base "${BASE_BRANCH}" --title "${TITLE}" --body "${BODY}" ${DRAFT_FLAG} --json url --jq .url)
echo "Created PR: ${PR_URL}"
CREATE_OUT=$(gh pr create --head "${HEAD_BRANCH}" --base "${BASE_BRANCH}" --title "${TITLE}" --body "${BODY}" ${DRAFT_FLAG})
echo "$CREATE_OUT"
PR_URL=$(echo "$CREATE_OUT" | grep -Eo 'https://github\.com/[^ ]+/pull/[0-9]+' | head -n 1 || true)
if [ -n "${PR_URL}" ]; then
echo "Created PR: ${PR_URL}"
else
echo "::warning::PR created but URL could not be parsed from output."
fi
fi
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "wincc-oa-tools-pack",
"displayName": "WinCC OA Tools Pack",
"publisher": "mPokornyETM",
"version": "0.0.7",
"version": "0.0.8",
"engines": {
"vscode": "^1.60.0"
},
Expand Down
Loading