fix: Actions for contributors (#4905)

This commit is contained in:
Dhruwang Jariwala
2025-03-10 21:34:17 +05:30
committed by GitHub
parent b21827cb32
commit da4211f0b0
2 changed files with 20 additions and 12 deletions
@@ -5,7 +5,7 @@ permissions:
on:
workflow_dispatch:
pull_request:
pull_request_target:
types: [opened, synchronize, reopened]
jobs:
@@ -14,6 +14,13 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.base.ref }}
- name: Checkout PR
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Setup Node.js
uses: actions/setup-node@v4
+12 -11
View File
@@ -3,7 +3,7 @@ permissions:
contents: read
on:
pull_request:
pull_request_target:
types: [closed]
branches:
- main
@@ -23,18 +23,16 @@ jobs:
- name: Get source branch name
id: branch-name
run: |
# For PR merges, use the head ref from the pull request event
SOURCE_BRANCH="${{ github.head_ref }}"
RAW_BRANCH="${{ github.head_ref }}"
SOURCE_BRANCH=$(echo "$RAW_BRANCH" | sed 's/[^a-zA-Z0-9._\/-]//g')
# Only remove username prefix if needed
if [[ "$SOURCE_BRANCH" =~ ^[a-zA-Z0-9][a-zA-Z0-9-]+/ ]]; then
PREFIX=${SOURCE_BRANCH%%/*}
if [[ ! "$PREFIX" =~ ^(feature|fix|bugfix|hotfix|release|chore|docs|test|refactor|style|perf|build|ci|revert)$ ]]; then
SOURCE_BRANCH=${SOURCE_BRANCH#*/}
fi
fi
echo "SOURCE_BRANCH=$SOURCE_BRANCH" >> $GITHUB_ENV
# Safely add to environment variables using GitHub's recommended method
# This prevents environment variable injection attacks
echo "SOURCE_BRANCH<<EOF" >> $GITHUB_ENV
echo "$SOURCE_BRANCH" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
echo "Detected source branch: $SOURCE_BRANCH"
- name: Setup Node.js
@@ -53,6 +51,7 @@ jobs:
--filter-tag "draft:${SOURCE_BRANCH}" \
--tag production \
--untag "draft:${SOURCE_BRANCH}"
--verbose
- name: Tag unused production keys as Deprecated
run: |
@@ -60,6 +59,7 @@ jobs:
--api-key ${{ secrets.TOLGEE_API_KEY }} \
--filter-not-extracted --filter-tag production \
--tag deprecated --untag production
--verbose
- name: Tag unused draft:current-branch keys as Deprecated
run: |
@@ -67,6 +67,7 @@ jobs:
--api-key ${{ secrets.TOLGEE_API_KEY }} \
--filter-not-extracted --filter-tag "draft:${SOURCE_BRANCH}" \
--tag deprecated --untag "draft:${SOURCE_BRANCH}"
--verbose
- name: Sync with backup
run: |