fix: current branch name (#4823)

This commit is contained in:
Dhruwang Jariwala
2025-02-26 19:09:09 +05:30
committed by GitHub
parent 75315ea2c5
commit 1373863af5
6 changed files with 63 additions and 6 deletions

View File

@@ -15,6 +15,55 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # This ensures we get the full git history
- name: Get source branch name
id: branch-name
run: |
# Get the most recent merge commit
MERGE_COMMIT=$(git log --merges -n 1 --format="%H")
if [ -n "$MERGE_COMMIT" ]; then
# Extract the source branch name from the merge commit message
SOURCE_BRANCH=$(git log -1 --format="%s" $MERGE_COMMIT | grep -oP "from '?\K[^']*(?='?)" || echo "")
if [ -z "$SOURCE_BRANCH" ]; then
# Alternative method: get the first parent's branch
SOURCE_BRANCH=$(git name-rev --name-only $(git log -1 --merges --pretty=format:"%P" | cut -d' ' -f1))
SOURCE_BRANCH=${SOURCE_BRANCH#remotes/origin/}
SOURCE_BRANCH=${SOURCE_BRANCH%~*}
fi
# Only remove username prefix if it matches a GitHub username pattern
# GitHub usernames are alphanumeric with hyphens, but cannot start with hyphens
# This regex matches patterns like "username/" but preserves "feature/" prefixes
if [[ "$SOURCE_BRANCH" =~ ^[a-zA-Z0-9][a-zA-Z0-9-]+/ ]]; then
# Check if this looks like a username prefix (not a feature branch prefix)
PREFIX=${SOURCE_BRANCH%%/*}
# Common feature branch prefixes to preserve
if [[ ! "$PREFIX" =~ ^(feature|fix|bugfix|hotfix|release|chore|docs|test|refactor|style|perf|build|ci|revert)$ ]]; then
# If not a common branch prefix, assume it's a username and remove it
SOURCE_BRANCH=${SOURCE_BRANCH#*/}
fi
fi
echo "SOURCE_BRANCH=$SOURCE_BRANCH" >> $GITHUB_ENV
else
echo "No merge commit found, using current branch"
CURRENT_BRANCH=${GITHUB_REF##*/}
# Apply the same username vs feature prefix logic
if [[ "$CURRENT_BRANCH" =~ ^[a-zA-Z0-9][a-zA-Z0-9-]+/ ]]; then
PREFIX=${CURRENT_BRANCH%%/*}
if [[ ! "$PREFIX" =~ ^(feature|fix|bugfix|hotfix|release|chore|docs|test|refactor|style|perf|build|ci|revert)$ ]]; then
CURRENT_BRANCH=${CURRENT_BRANCH#*/}
fi
fi
echo "SOURCE_BRANCH=$CURRENT_BRANCH" >> $GITHUB_ENV
fi
# Log the branch name for debugging
echo "Detected source branch: $SOURCE_BRANCH"
- name: Setup Node.js
uses: actions/setup-node@v4
@@ -26,13 +75,12 @@ jobs:
- name: Tag Production Keys
run: |
BRANCH_NAME=${GITHUB_REF##*/}
npx tolgee tag \
--api-key ${{ secrets.TOLGEE_API_KEY }} \
--filter-extracted \
--filter-tag "draft:${BRANCH_NAME}" \
--filter-tag "draft:${SOURCE_BRANCH}" \
--tag production \
--untag "draft:${BRANCH_NAME}"
--untag "draft:${SOURCE_BRANCH}"
- name: Tag unused production keys as Deprecated
run: |
@@ -43,11 +91,10 @@ jobs:
- name: Tag unused draft:current-branch keys as Deprecated
run: |
BRANCH_NAME=${GITHUB_REF##*/}
npx tolgee tag \
--api-key ${{ secrets.TOLGEE_API_KEY }} \
--filter-not-extracted --filter-tag "draft:${BRANCH_NAME}" \
--tag deprecated --untag "draft:${BRANCH_NAME}"
--filter-not-extracted --filter-tag "draft:${SOURCE_BRANCH}" \
--tag deprecated --untag "draft:${SOURCE_BRANCH}"
- name: Sync with backup
run: |

View File

@@ -1447,6 +1447,8 @@
"heading": "Überschrift",
"hidden_field_added_successfully": "Verstecktes Feld erfolgreich hinzugefügt",
"hide_advanced_settings": "Erweiterte Einstellungen ausblenden",
"hide_back_button": "'Zurück'-Button ausblenden",
"hide_back_button_description": "Den Zurück-Button in der Umfrage nicht anzeigen",
"hide_logo": "Logo verstecken",
"hide_progress_bar": "Fortschrittsbalken ausblenden",
"hide_the_logo_in_this_specific_survey": "Logo in dieser speziellen Umfrage verstecken",

View File

@@ -1447,6 +1447,8 @@
"heading": "Heading",
"hidden_field_added_successfully": "Hidden field added successfully",
"hide_advanced_settings": "Hide advanced settings",
"hide_back_button": "Hide 'Back' button",
"hide_back_button_description": "Do not display the back button in the survey",
"hide_logo": "Hide logo",
"hide_progress_bar": "Hide progress bar",
"hide_the_logo_in_this_specific_survey": "Hide the logo in this specific survey",

View File

@@ -1447,6 +1447,8 @@
"heading": "En-tête",
"hidden_field_added_successfully": "Champ caché ajouté avec succès",
"hide_advanced_settings": "Cacher les paramètres avancés",
"hide_back_button": "Masquer le bouton 'Retour'",
"hide_back_button_description": "Ne pas afficher le bouton retour dans l'enquête",
"hide_logo": "Cacher le logo",
"hide_progress_bar": "Cacher la barre de progression",
"hide_the_logo_in_this_specific_survey": "Cacher le logo dans cette enquête spécifique",

View File

@@ -1447,6 +1447,8 @@
"heading": "Título",
"hidden_field_added_successfully": "Campo oculto adicionado com sucesso",
"hide_advanced_settings": "Ocultar configurações avançadas",
"hide_back_button": "Ocultar botão 'Voltar'",
"hide_back_button_description": "Não exibir o botão de voltar na pesquisa",
"hide_logo": "Esconder logo",
"hide_progress_bar": "Esconder barra de progresso",
"hide_the_logo_in_this_specific_survey": "Esconder o logo nessa pesquisa específica",

View File

@@ -1447,6 +1447,8 @@
"heading": "標題",
"hidden_field_added_successfully": "隱藏欄位已成功新增",
"hide_advanced_settings": "隱藏進階設定",
"hide_back_button": "隱藏「Back」按鈕",
"hide_back_button_description": "不要在問卷中顯示返回按鈕",
"hide_logo": "隱藏標誌",
"hide_progress_bar": "隱藏進度列",
"hide_the_logo_in_this_specific_survey": "在此特定問卷中隱藏標誌",