-
Notifications
You must be signed in to change notification settings - Fork 180
allow staging pull requests into main #1263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1320,18 +1320,21 @@ jobs: | |||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||
| VERSION="${{ needs.bump-version.outputs.version }}" | ||||||||||||||||||||||||||||||
| TARGET_BRANCH="${{ inputs.bump_target_branch || 'dev' }}" | ||||||||||||||||||||||||||||||
| # Use version-based branch name for idempotency | ||||||||||||||||||||||||||||||
| BRANCH_NAME="ci/bump-mobile-version-${VERSION}" | ||||||||||||||||||||||||||||||
| # Add timestamp to branch name to avoid collisions | ||||||||||||||||||||||||||||||
| TIMESTAMP=$(date +%s%N | cut -b1-13) # Milliseconds since epoch (13 digits) | ||||||||||||||||||||||||||||||
| BRANCH_NAME="ci/bump-mobile-version-${VERSION}-${TIMESTAMP}" | ||||||||||||||||||||||||||||||
| PR_TITLE="${{ steps.platforms.outputs.pr_title }}" | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| git config user.name "github-actions[bot]" | ||||||||||||||||||||||||||||||
| git config user.email "github-actions[bot]@users.noreply.github.com" | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| # Check if branch already exists (idempotent PR creation) | ||||||||||||||||||||||||||||||
| if git ls-remote --heads origin "${BRANCH_NAME}" | grep -q "${BRANCH_NAME}"; then | ||||||||||||||||||||||||||||||
| echo "⚠️ Branch ${BRANCH_NAME} already exists" | ||||||||||||||||||||||||||||||
| echo "ℹ️ Version bump PR may already exist for version ${VERSION}" | ||||||||||||||||||||||||||||||
| # Check if a PR already exists for this version (avoid duplicate PRs) | ||||||||||||||||||||||||||||||
| EXISTING_PR=$(gh pr list --base "${TARGET_BRANCH}" --state open --json number,title,headRefName --jq ".[] | select(.title | contains(\"${VERSION}\")) | .number" | head -1) | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| if [ -n "$EXISTING_PR" ]; then | ||||||||||||||||||||||||||||||
| echo "⚠️ PR #${EXISTING_PR} already exists for version ${VERSION}" | ||||||||||||||||||||||||||||||
| echo "ℹ️ Skipping PR creation to avoid duplicates" | ||||||||||||||||||||||||||||||
| echo "ℹ️ Existing PR: https://github.com/${{ github.repository }}/pull/${EXISTING_PR}" | ||||||||||||||||||||||||||||||
| exit 0 | ||||||||||||||||||||||||||||||
|
Comment on lines
+1332
to
1338
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tighten the duplicate PR detection to avoid false skips. Filtering on Apply this diff: - EXISTING_PR=$(gh pr list --base "${TARGET_BRANCH}" --state open --json number,title,headRefName --jq ".[] | select(.title | contains(\"${VERSION}\")) | .number" | head -1)
+ EXISTING_PR=$(gh pr list --base "${TARGET_BRANCH}" --state open --json number,headRefName --jq ".[] | select(.headRefName | startswith(\"ci/bump-mobile-version-${VERSION}\")) | .number" | head -1)📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Harden the head ref check to avoid command injection.
Interpolating
${{ github.head_ref }}directly inside the shell script leaves the step vulnerable to command injection if the branch name is crafted maliciously (see GitHub’s security guidance). Please pass the value throughenv:and reference the environment variable inside the script instead.Apply this diff:
🧰 Tools
🪛 actionlint (1.7.7)
12-12: "github.head_ref" is potentially untrusted. avoid using it directly in inline scripts. instead, pass it through an environment variable. see https://docs.github.com/en/actions/security-for-github-actions/security-guides/security-hardening-for-github-actions for more details
(expression)
🤖 Prompt for AI Agents