Skip to content

Commit

Permalink
Exclude workflow changes from being backported
Browse files Browse the repository at this point in the history
The backport script for the PRs does not have the permission to backport
PRs which include workflow changes. So, these PRs are excluded from
being automatically backported.

Failed CI run:

https://github.com/timescale/timescaledb/actions/runs/5387338161/
   jobs/9780701395

> refusing to allow a GitHub App to create or update workflow
> `.github/workflows/xxx.yaml` without `workflows` permission)
  • Loading branch information
jnidzwetzki committed Jul 3, 2023
1 parent 9bbf521 commit b9a58dd
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion scripts/backport.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,21 @@ def report_backport_not_done(original_pr, reason, details=None):
report_backport_not_done(original_pr, "cherry-pick failed", details)
continue

# We don't have the permission to modify workflows
changed_files = {file.filename for file in original_pr.get_files()}
changed_workflow_files = {
filename
for filename in changed_files
if filename.startswith(".github/workflows/")
}
if changed_workflow_files:
details = (
f"The PR touches a workflow file '{list(changed_workflow_files)[0]}' "
" and cannot be backported automatically"
)
report_backport_not_done(original_pr, "backport failed", details)
continue

# Push the backport branch.
git_check(f"push --quiet {target_remote} @:refs/heads/{backport_branch}")

Expand All @@ -423,7 +438,6 @@ def report_backport_not_done(original_pr, reason, details=None):
# Do not merge the PR automatically if it changes some particularly
# conflict-prone files that are better to review manually. Also mention this
# in the description.
changed_files = {file.filename for file in original_pr.get_files()}
stopper_files = changed_files.intersection(
["sql/updates/latest-dev.sql", "sql/updates/reverse-dev.sql"]
)
Expand Down

0 comments on commit b9a58dd

Please sign in to comment.