Skip to content

πŸ™Œ OpenHands: AI-Driven Development

Update workflow shell context handling (#14478)

Graham Neubig0916b25251de
diff --git a/.github/workflows/enterprise-check-migrations.yml b/.github/workflows/enterprise-check-migrations.yml
index 4bce3397d8..89ec7afee7 100644
--- a/.github/workflows/enterprise-check-migrations.yml
+++ b/.github/workflows/enterprise-check-migrations.yml
@@ -17,14 +17,19 @@ jobs:
- name: Fetch base branch
- run: git fetch origin ${{ github.event.pull_request.base.ref }}
+ env:
+ BASE_REF: ${{ github.event.pull_request.base.ref }}
+ run: git fetch origin "$BASE_REF"
- name: Check if base branch is ancestor of PR
id: check_up_to_date
shell: bash
+ env:
+ BASE_REF: ${{ github.event.pull_request.base.ref }}
+ HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: |
- BASE="origin/${{ github.event.pull_request.base.ref }}"
- HEAD="${{ github.event.pull_request.head.sha }}"
+ BASE="origin/${BASE_REF}"
+ HEAD="$HEAD_SHA"
if git merge-base --is-ancestor "$BASE" "$HEAD"; then
echo "We're up to date with base $BASE"
exit 0
diff --git a/.github/workflows/ghcr-build.yml b/.github/workflows/ghcr-build.yml
index 0bff67076a..2e3f9a2dbe 100644
--- a/.github/workflows/ghcr-build.yml
+++ b/.github/workflows/ghcr-build.yml
@@ -54,7 +54,9 @@ jobs:
- name: Get short SHA
id: short_sha
- run: echo "SHORT_SHA=$(echo ${{ github.event.pull_request.head.sha }} | cut -c1-7)" >> "$GITHUB_OUTPUT"
+ env:
+ PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
+ run: printf 'SHORT_SHA=%s\n' "${PR_HEAD_SHA:0:7}" >> "$GITHUB_OUTPUT"
- name: Update PR Description
env:
diff --git a/.github/workflows/issue-duplicate-checker.yml b/.github/workflows/issue-duplicate-checker.yml
index f86a5aed88..53d9fedf5c 100644
--- a/.github/workflows/issue-duplicate-checker.yml
+++ b/.github/workflows/issue-duplicate-checker.yml
@@ -41,8 +41,10 @@ jobs:
uses: actions/checkout@v6
- name: Clone repository
+ env:
+ REPOSITORY: ${{ github.repository }}
run: |
- git clone --depth 1 "https://github.com/${{ github.repository }}.git" /tmp/repo-clone
+ git clone --depth 1 "https://github.com/${REPOSITORY}.git" /tmp/repo-clone
echo "Repository HEAD: $(git -C /tmp/repo-clone rev-parse --short HEAD)"
- name: Summarize smoke test
@@ -92,9 +94,10 @@ jobs:
GITHUB_TOKEN: ${{ secrets.OPENHANDS_BOT_GITHUB_PAT_PUBLIC || github.token }}
ISSUE_NUMBER: ${{ github.event.issue.number || inputs.issue_number }}
OUTPUT_PATH: ${{ runner.temp }}/issue-duplicate-check-result.json
+ REPOSITORY: ${{ github.repository }}
run: |
python scripts/issue_duplicate_check_openhands.py \
- --repository "${{ github.repository }}" \
+ --repository "$REPOSITORY" \
--issue-number "$ISSUE_NUMBER" \
--output "$OUTPUT_PATH"
test -f "$OUTPUT_PATH" || {
@@ -451,7 +454,7 @@ jobs:
CLOSE_AFTER_DAYS: ${{ inputs.close_after_days || '3' }}
run: |
python scripts/auto_close_duplicate_issues.py \
- --repository "${{ github.repository }}" \
+ --repository "$REPOSITORY" \
--close-after-days "$CLOSE_AFTER_DAYS" | tee "$RUNNER_TEMP/auto-close-summary.json"
status=${PIPESTATUS[0]}
if [ "$status" -ne 0 ]; then
diff --git a/.github/workflows/npm-publish-ui.yml b/.github/workflows/npm-publish-ui.yml
index f3e7b68245..c8f8a4be56 100644
--- a/.github/workflows/npm-publish-ui.yml
+++ b/.github/workflows/npm-publish-ui.yml
@@ -81,9 +81,11 @@ jobs:
- name: Check if package already exists on npm
id: npm-check
working-directory: ./openhands-ui
+ env:
+ CURRENT_VERSION: ${{ needs.check-version.outputs.current-version }}
run: |
PACKAGE_NAME=$(jq -r .name package.json)
- VERSION="${{ needs.check-version.outputs.current-version }}"
+ VERSION="$CURRENT_VERSION"
# Check if this version already exists on npm
if npm view "$PACKAGE_NAME@$VERSION" version 2>/dev/null; then
@@ -96,13 +98,17 @@ jobs:
- name: Setup npm authentication
if: steps.npm-check.outputs.already-exists == 'false'
+ env:
+ NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
- echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
+ echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
- name: Publish to npm
if: steps.npm-check.outputs.already-exists == 'false'
working-directory: ./openhands-ui
+ env:
+ CURRENT_VERSION: ${{ needs.check-version.outputs.current-version }}
run: |
# The prepublishOnly script will run automatically and build the package
npm publish
- echo "βœ… Successfully published @openhands/ui@${{ needs.check-version.outputs.current-version }} to npm"
+ echo "βœ… Successfully published @openhands/ui@${CURRENT_VERSION} to npm"
diff --git a/.github/workflows/pr-artifacts.yml b/.github/workflows/pr-artifacts.yml
index db6e1fbf71..e9262a3220 100644
--- a/.github/workflows/pr-artifacts.yml
+++ b/.github/workflows/pr-artifacts.yml
@@ -23,8 +23,11 @@ jobs:
steps:
- name: Check if fork PR
id: check-fork
+ env:
+ HEAD_REPO: ${{ github.event.pull_request.head.repo.full_name }}
+ BASE_REPO: ${{ github.event.pull_request.base.repo.full_name }}
run: |
- if [ "${{ github.event.pull_request.head.repo.full_name }}" != "${{ github.event.pull_request.base.repo.full_name }}" ]; then
+ if [ "$HEAD_REPO" != "$BASE_REPO" ]; then
echo "is_fork=true" >> $GITHUB_OUTPUT
echo "::notice::Fork PR detected - skipping auto-cleanup (manual removal required)"
else
diff --git a/.github/workflows/pypi-release.yml b/.github/workflows/pypi-release.yml
index 8414f686c1..a3a03a0acf 100644
--- a/.github/workflows/pypi-release.yml
+++ b/.github/workflows/pypi-release.yml
@@ -37,4 +37,6 @@ jobs:
- name: Build poetry project
run: ./build.sh
- name: publish
- run: poetry publish -u __token__ -p ${{ secrets.PYPI_TOKEN }}
+ env:
+ PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
+ run: poetry publish -u __token__ -p "$PYPI_TOKEN"
diff --git a/.github/workflows/tag-image.yml b/.github/workflows/tag-image.yml
index 91f4a19d3a..b285c8b023 100644
--- a/.github/workflows/tag-image.yml
+++ b/.github/workflows/tag-image.yml
@@ -44,11 +44,12 @@ jobs:
env:
SRC: ${{ matrix.image }}:sha-${{ github.sha }}
TAGS: ${{ steps.meta.outputs.tags }}
+ COMMIT_SHA: ${{ github.sha }}
shell: bash
run: |
set -euo pipefail
if ! docker buildx imagetools inspect "$SRC" > /dev/null 2>&1; then
- echo "::error::Source image $SRC does not exist. The Docker workflow for commit ${{ github.sha }} may not have completed successfully. Re-run this workflow once the build finishes."
+ echo "::error::Source image $SRC does not exist. The Docker workflow for commit $COMMIT_SHA may not have completed successfully. Re-run this workflow once the build finishes."
exit 1
fi
args=()