diff --git a/.github/workflows/commit-message-check.yml b/.github/workflows/commit-message-check.yml new file mode 100644 index 0000000000..172bc8038d --- /dev/null +++ b/.github/workflows/commit-message-check.yml @@ -0,0 +1,74 @@ +name: Commit Message Check + +on: + push: + branches: + - 'feature/**' + - 'bugfix/**' + pull_request: + branches: + - main + - develop + +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Validate commits + run: | + BRANCH="$GITHUB_REF_NAME" + BRANCH_KEY=$(echo "$BRANCH" | grep -oE '[A-Z]+-[0-9]+' | head -1) + BEFORE="${{ github.event.before }}" + AFTER="${{ github.event.after }}" + + echo "Branch: $BRANCH" + echo "Branch Key: $BRANCH_KEY" + echo "" + + if [ -z "$BRANCH_KEY" ]; then + echo "✅ No Jira key in branch name. Skipping." + exit 0 + fi + + # Get commits (push event) + if [ "$BEFORE" = "0000000000000000000000000000000000000000" ]; then + COMMITS=$(git log --format="%H|%s" "$AFTER" -10) + elif [ -n "$BEFORE" ] && [ -n "$AFTER" ]; then + COMMITS=$(git log --format="%H|%s" "$BEFORE..$AFTER") + else + # Pull request — check all commits in PR + COMMITS=$(git log --format="%H|%s" "origin/${{ github.base_ref }}..HEAD") + fi + + FAIL=0 + while IFS= read -r line; do + [ -z "$line" ] && continue + SHA=$(echo "$line" | cut -d'|' -f1 | cut -c1-7) + MSG=$(echo "$line" | cut -d'|' -f2-) + KEY=$(echo "$MSG" | grep -oE '[A-Z]+-[0-9]+' | head -1) + + if [ -z "$KEY" ]; then + echo "❌ [$SHA] Missing Jira key → \"$MSG\"" + FAIL=1 + continue + fi + + if echo "$BRANCH" | grep -q "^bugfix/" && [ "$KEY" != "$BRANCH_KEY" ]; then + echo "❌ [$SHA] Key $KEY ≠ branch key $BRANCH_KEY → \"$MSG\"" + FAIL=1 + continue + fi + + echo "✅ [$SHA] $MSG" + done <<< "$COMMITS" + + echo "" + if [ "$FAIL" -eq 1 ]; then + echo "❌ FAILED" + exit 1 + fi + echo "✅ ALL COMMITS VALID" diff --git a/.github/workflows/create-branches.yml b/.github/workflows/create-branches.yml new file mode 100644 index 0000000000..3265e0accf --- /dev/null +++ b/.github/workflows/create-branches.yml @@ -0,0 +1,56 @@ +name: Create branches in multiple repos + +on: + workflow_dispatch: + inputs: + jira_key: + description: "Jira issue key (e.g. ABC-123)" + required: true + base_branch: + description: "Base branch name" + required: false + default: "main" + +jobs: + create-branches: + runs-on: ubuntu-latest + + steps: + - name: Create branches in repos + env: + GH_TOKEN: ${{ secrets.GH_PAT }} + JIRA_KEY: ${{ github.event.inputs.jira_key }} + BASE_BRANCH: ${{ github.event.inputs.base_branch }} + run: | + set -e + + ORG="" + BRANCH_NAME="feature/${JIRA_KEY}" + + REPOS=( + "hello-world" + "New Actions" + ) + + for REPO in "${REPOS[@]}"; do + echo "Creating branch in $ORG/$REPO" + + BASE_SHA=$(curl -s \ + -H "Authorization: token $GH_TOKEN" \ + -H "Accept: application/vnd.github+json" \ + "https://api.github.com/repos/$ORG/$REPO/git/ref/heads/$BASE_BRANCH" \ + | jq -r .object.sha) + + if [ "$BASE_SHA" = "null" ]; then + echo "Base branch '$BASE_BRANCH' not found in $REPO" + continue + fi + + curl -s -X POST \ + -H "Authorization: token $GH_TOKEN" \ + -H "Accept: application/vnd.github+json" \ + "https://api.github.com/repos/$ORG/$REPO/git/refs" \ + -d "{\"ref\":\"refs/heads/$BRANCH_NAME\",\"sha\":\"$BASE_SHA\"}" + + echo "Branch $BRANCH_NAME created in $REPO" + done diff --git a/.github/workflows/manual.yml b/.github/workflows/manual.yml new file mode 100644 index 0000000000..9ef69e21f2 --- /dev/null +++ b/.github/workflows/manual.yml @@ -0,0 +1,75 @@ +name: Create branches in multiple repos + +on: + workflow_dispatch: + inputs: + jira_key: + description: "Jira issue key (e.g. ABC-123)" + required: true + +jobs: + create-branches: + runs-on: ubuntu-latest + + steps: + - name: Create branches in repos + env: + GH_TOKEN: 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 + JIRA_KEY: ${{ github.event.inputs.jira_key }} + run: | + set -e + + ORG="Nandishn969" + BRANCH_NAME="feature/${JIRA_KEY}" + + REPOS=( + "hello-world" + "New-Actions" + "Jira-Cloud" + ) + + for REPO in "${REPOS[@]}"; do + echo "--------------------------------------" + echo "Processing repo: $ORG/$REPO" + + # 1️⃣ Get default branch + DEFAULT_BRANCH=$(curl -s \ + -H "Authorization: Bearer $GH_TOKEN" \ + -H "Accept: application/vnd.github+json" \ + https://api.github.com/repos/$ORG/$REPO \ + | jq -r .default_branch) + + if [ "$DEFAULT_BRANCH" = "null" ] || [ -z "$DEFAULT_BRANCH" ]; then + echo "❌ Could not determine default branch for $REPO" + continue + fi + + echo "Default branch is: $DEFAULT_BRANCH" + + # 2️⃣ Get SHA of default branch + BASE_SHA=$(curl -s \ + -H "Authorization: Bearer $GH_TOKEN" \ + -H "Accept: application/vnd.github+json" \ + https://api.github.com/repos/$ORG/$REPO/git/ref/heads/$DEFAULT_BRANCH \ + | jq -r .object.sha) + + if [ "$BASE_SHA" = "null" ] || [ -z "$BASE_SHA" ]; then + echo "❌ Failed to fetch SHA for $DEFAULT_BRANCH in $REPO" + continue + fi + + # 3️⃣ Create branch + CREATE_RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" -X POST \ + -H "Authorization: Bearer $GH_TOKEN" \ + -H "Accept: application/vnd.github+json" \ + https://api.github.com/repos/$ORG/$REPO/git/refs \ + -d "{\"ref\":\"refs/heads/$BRANCH_NAME\",\"sha\":\"$BASE_SHA\"}") + + if [ "$CREATE_RESPONSE" = "201" ]; then + echo "✅ Branch $BRANCH_NAME created in $REPO" + elif [ "$CREATE_RESPONSE" = "422" ]; then + echo "⚠️ Branch $BRANCH_NAME already exists in $REPO" + else + echo "❌ Failed to create branch in $REPO (HTTP $CREATE_RESPONSE)" + fi + done diff --git a/actions/workflows/manual.yml b/actions/workflows/manual.yml new file mode 100644 index 0000000000..3265e0accf --- /dev/null +++ b/actions/workflows/manual.yml @@ -0,0 +1,56 @@ +name: Create branches in multiple repos + +on: + workflow_dispatch: + inputs: + jira_key: + description: "Jira issue key (e.g. ABC-123)" + required: true + base_branch: + description: "Base branch name" + required: false + default: "main" + +jobs: + create-branches: + runs-on: ubuntu-latest + + steps: + - name: Create branches in repos + env: + GH_TOKEN: ${{ secrets.GH_PAT }} + JIRA_KEY: ${{ github.event.inputs.jira_key }} + BASE_BRANCH: ${{ github.event.inputs.base_branch }} + run: | + set -e + + ORG="" + BRANCH_NAME="feature/${JIRA_KEY}" + + REPOS=( + "hello-world" + "New Actions" + ) + + for REPO in "${REPOS[@]}"; do + echo "Creating branch in $ORG/$REPO" + + BASE_SHA=$(curl -s \ + -H "Authorization: token $GH_TOKEN" \ + -H "Accept: application/vnd.github+json" \ + "https://api.github.com/repos/$ORG/$REPO/git/ref/heads/$BASE_BRANCH" \ + | jq -r .object.sha) + + if [ "$BASE_SHA" = "null" ]; then + echo "Base branch '$BASE_BRANCH' not found in $REPO" + continue + fi + + curl -s -X POST \ + -H "Authorization: token $GH_TOKEN" \ + -H "Accept: application/vnd.github+json" \ + "https://api.github.com/repos/$ORG/$REPO/git/refs" \ + -d "{\"ref\":\"refs/heads/$BRANCH_NAME\",\"sha\":\"$BASE_SHA\"}" + + echo "Branch $BRANCH_NAME created in $REPO" + done diff --git a/pom.xml b/pom.xml index 187d2a36a0..5c10d417c1 100644 --- a/pom.xml +++ b/pom.xml @@ -220,8 +220,4 @@ http://github.com/jleetutorial/maven-project - - 3.0.3 - - diff --git a/test.txt b/test.txt new file mode 100644 index 0000000000..059336e337 --- /dev/null +++ b/test.txt @@ -0,0 +1 @@ +kujhfked diff --git a/testing.txt b/testing.txt new file mode 100644 index 0000000000..0919405720 --- /dev/null +++ b/testing.txt @@ -0,0 +1 @@ +Testing githiub validations diff --git a/text.txt b/text.txt new file mode 100644 index 0000000000..cefd3146d1 --- /dev/null +++ b/text.txt @@ -0,0 +1,2 @@ +hikujhedoed +dwdh diff --git a/text1.txt b/text1.txt new file mode 100644 index 0000000000..b42c3c74a7 --- /dev/null +++ b/text1.txt @@ -0,0 +1 @@ +heinfdkjdh