Skip to content

Commit f8fa5ce

Browse files
committed
script fix
1 parent 2c060a5 commit f8fa5ce

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

template/.github/workflows/dependabot-post-update.yaml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,29 +30,30 @@ jobs:
3030
run: python3 .github/workflows/hash_git_files.py . --for-devcontainer-config-update --exit-zero
3131

3232
- name: Commit & push changes
33+
id: commit
3334
run: |
34-
# only commit if there are changes
3535
if ! git diff --quiet; then
3636
git add .
3737
git commit -m "chore: apply post-Dependabot script changes [dependabot skip]"
3838
git push origin HEAD:${{ github.event.pull_request.head.ref }}
39+
echo "pushed=true" >> $GITHUB_OUTPUT
3940
else
40-
echo "No changes to commit"
41+
echo "pushed=false" >> $GITHUB_OUTPUT
4142
fi
4243
4344
- name: Dispatch CI on PR branch # pushes done by GITHUB_TOKEN don't trigger workflows, so we have to restart the CI job manually, see https://docs.github.com/en/actions/using-workflows/triggering-a-workflow#triggering-a-workflow-from-a-workflow
45+
if: steps.commit.outputs.pushed == 'true'
4446
uses: actions/github-script@v7.0.1
4547
with:
4648
github-token: ${{ secrets.GITHUB_TOKEN }}
4749
script: |
48-
const run = context.payload.workflow_run;
49-
const pr = run.pull_requests[0];
50+
const pr = context.payload.pull_request;
5051
if (!pr) {
51-
throw new Error("No pull request linked to this workflow_run event; aborting dispatch.");
52+
throw new Error("No pull_request found in payload; aborting dispatch.");
5253
}
5354
await github.actions.createWorkflowDispatch({
54-
owner: context.repo.owner,
55-
repo: context.repo.repo,
55+
owner: context.repo.owner,
56+
repo: context.repo.repo,
5657
workflow_id: "ci.yaml",
57-
ref: run.head_branch,
58+
ref: pr.head.ref,
5859
});

0 commit comments

Comments
 (0)