-
Notifications
You must be signed in to change notification settings - Fork 5
fix: harden generate-changeset workflow #1069
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 |
|---|---|---|
|
|
@@ -25,15 +25,6 @@ jobs: | |
| app-id: ${{ secrets.ECOSPARK_APP_ID }} | ||
| private-key: ${{ secrets.ECOSPARK_APP_PRIVATE_KEY }} | ||
|
|
||
| - name: Checkout PR branch | ||
| uses: actions/checkout@v6 | ||
| with: | ||
| ref: ${{ github.event.pull_request.head.ref }} | ||
| repository: ${{ github.event.pull_request.head.repo.full_name }} | ||
| token: ${{ steps.generate_token.outputs.token }} | ||
| fetch-depth: 2 | ||
| persist-credentials: false | ||
|
|
||
| - name: Checkout base branch scripts | ||
| uses: actions/checkout@v6 | ||
| with: | ||
|
|
@@ -46,11 +37,62 @@ jobs: | |
| with: | ||
| node-version: 24 | ||
|
|
||
| - name: Generate or remove changeset | ||
| - name: Analyze PR and generate changeset | ||
| id: analyze | ||
| env: | ||
| GH_TOKEN: ${{ steps.generate_token.outputs.token }} | ||
| PR_NUMBER: ${{ github.event.pull_request.number }} | ||
| PR_TITLE: ${{ github.event.pull_request.title }} | ||
| PR_BODY: ${{ github.event.pull_request.body }} | ||
| PR_REPO: ${{ github.event.pull_request.head.repo.full_name }} | ||
| PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }} | ||
| run: node base-scripts/.github/scripts/generate-changeset.mjs | ||
|
|
||
| - name: Checkout PR branch | ||
| if: steps.analyze.outputs.action == 'write' || steps.analyze.outputs.action == 'remove' | ||
| uses: actions/checkout@v6 | ||
| with: | ||
| ref: ${{ github.event.pull_request.head.sha }} | ||
|
cursor[bot] marked this conversation as resolved.
|
||
| repository: ${{ github.event.pull_request.head.repo.full_name }} | ||
| token: ${{ steps.generate_token.outputs.token }} | ||
| fetch-depth: 1 | ||
| persist-credentials: false | ||
|
|
||
| - name: Configure git | ||
| if: steps.analyze.outputs.action == 'write' || steps.analyze.outputs.action == 'remove' | ||
| env: | ||
| GH_APP_TOKEN: ${{ steps.generate_token.outputs.token }} | ||
| PR_HEAD_REPO: ${{ github.event.pull_request.head.repo.full_name }} | ||
| run: | | ||
| git config user.name 'squiggler-app[bot]' | ||
| git config user.email '265501495+squiggler-app[bot]@users.noreply.github.com' | ||
| git remote set-url origin "https://x-access-token:${GH_APP_TOKEN}@github.com/${PR_HEAD_REPO}.git" | ||
|
|
||
| - name: Write changeset and push | ||
| if: steps.analyze.outputs.action == 'write' | ||
| env: | ||
| CHANGESET_CONTENT: ${{ steps.analyze.outputs.changeset_content }} | ||
| CHANGESET_FILE: ${{ steps.analyze.outputs.changeset_file }} | ||
| PR_HEAD_REF: ${{ github.event.pull_request.head.ref }} | ||
| run: | | ||
| mkdir -p "$(dirname "$CHANGESET_FILE")" | ||
| printf '%s' "$CHANGESET_CONTENT" > "$CHANGESET_FILE" | ||
| git add "$CHANGESET_FILE" | ||
| if ! git diff --cached --quiet; then | ||
| git commit -m "chore: update auto-generated changeset for PR #${{ github.event.pull_request.number }}" | ||
| git push --force-with-lease origin "HEAD:${PR_HEAD_REF}" | ||
|
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.
|
||
| else | ||
| echo "No changes to changeset file" | ||
| fi | ||
|
|
||
| - name: Remove changeset and push | ||
| if: steps.analyze.outputs.action == 'remove' | ||
| env: | ||
| CHANGESET_FILE: ${{ steps.analyze.outputs.changeset_file }} | ||
| PR_HEAD_REF: ${{ github.event.pull_request.head.ref }} | ||
| run: | | ||
| if [ -f "$CHANGESET_FILE" ]; then | ||
| git rm "$CHANGESET_FILE" | ||
| git commit -m "chore: remove auto-generated changeset for PR #${{ github.event.pull_request.number }}" | ||
| git push --force-with-lease origin "HEAD:${PR_HEAD_REF}" | ||
| fi | ||


Uh oh!
There was an error while loading. Please reload this page.