Skip to content

Commit ae986f8

Browse files
fix(upgrade): fix repo URLs, make upgrade failures fatal, scope git add to fern/, fix heredoc escaping
Co-Authored-By: barry.zou <barry.zou@buildwithfern.com>
1 parent 28deede commit ae986f8

4 files changed

Lines changed: 37 additions & 12 deletions

File tree

actions/upgrade/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
runs-on: ubuntu-latest
3535
steps:
3636
- uses: actions/checkout@v4
37-
- uses: fern-api/fern-github-actions/actions/upgrade@v1
37+
- uses: fern-api/actions/upgrade@v1
3838
with:
3939
fern-token: ${{ secrets.FERN_TOKEN }}
4040
```

actions/upgrade/action.yml

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,15 @@ runs:
6565
FERN_TOKEN: ${{ inputs.fern-token }}
6666
run: |
6767
echo "Running fern upgrade..."
68-
${{ steps.cli.outputs.fern-cmd }} upgrade --yes || \
69-
echo "::warning::fern upgrade exited with non-zero code"
68+
${{ steps.cli.outputs.fern-cmd }} upgrade --yes
7069
7170
- name: Run fern generator upgrade
7271
shell: bash
7372
env:
7473
FERN_TOKEN: ${{ inputs.fern-token }}
7574
run: |
7675
echo "Running fern generator upgrade..."
77-
${{ steps.cli.outputs.fern-cmd }} generator upgrade --yes || \
78-
echo "::warning::fern generator upgrade exited with non-zero code"
76+
${{ steps.cli.outputs.fern-cmd }} generator upgrade --yes
7977
# TODO: FER-9669 — Check automation config before running upgrades
8078
8179
- name: Compute upgrade diff
@@ -93,6 +91,7 @@ runs:
9391
GH_TOKEN: ${{ inputs.github-token }}
9492
GITHUB_TOKEN: ${{ inputs.github-token }}
9593
PR_TITLE: ${{ steps.diff.outputs.pr-title }}
94+
PR_BODY: ${{ steps.diff.outputs.pr-body }}
9695
COMMIT_MSG: ${{ steps.diff.outputs.commit-msg }}
9796
run: |
9897
BRANCH="fern/upgrade"
@@ -114,8 +113,8 @@ runs:
114113
git fetch origin "$DEFAULT_BRANCH"
115114
git checkout -B "$BRANCH" "origin/$DEFAULT_BRANCH"
116115
117-
# Stage all changes
118-
git add -A
116+
# Stage only fern config changes (fern.config.json + generators.yml)
117+
git add fern/
119118
if git diff --cached --quiet; then
120119
echo "No changes to commit"
121120
echo "pr-url=" >> "$GITHUB_OUTPUT"
@@ -126,10 +125,8 @@ runs:
126125
git commit -m "$COMMIT_MSG"
127126
git push --force origin "$BRANCH"
128127
129-
# Write PR body to temp file to avoid shell escaping issues
130-
cat > /tmp/pr-body.md << 'PREOF'
131-
${{ steps.diff.outputs.pr-body }}
132-
PREOF
128+
# Write PR body to temp file via env var to avoid shell escaping issues
129+
printf '%s' "$PR_BODY" > /tmp/pr-body.md
133130
134131
# Create or update PR
135132
EXISTING_PR=$(gh pr list --head "$BRANCH" --state open --json number --jq '.[0].number // empty')

actions/upgrade/scripts/diff.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ function buildPrBody(diff) {
170170

171171
sections.push("---");
172172
sections.push(
173-
"\uD83E\uDD16 This PR was automatically created by [fern-upgrade](https://github.com/fern-api/fern-github-actions/tree/main/actions/upgrade)"
173+
"\uD83E\uDD16 This PR was automatically created by [fern-upgrade](https://github.com/fern-api/actions/tree/main/actions/upgrade)"
174174
);
175175

176176
return sections.join("\n");

pnpm-lock.yaml

Lines changed: 28 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)