Skip to content
This repository was archived by the owner on Mar 18, 2026. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 78 additions & 0 deletions .github/workflows/fast-forward.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Fast forward

on:
issue_comment:
types: [created, edited]

permissions:
contents: write
pull-requests: write
issues: write

jobs:
fast-forward:
if: ${{ (contains(github.event.comment.body, '/fast-forward')
|| github.event.comment.body == '/ff')
Comment on lines +14 to +15

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Match slash commands exactly instead of substring

Using contains(...) means any comment that merely mentions /fast-forward (and similarly /rebase) will trigger the job, so maintainers can accidentally launch merge/rebase actions while discussing commands in plain text. This should be constrained to exact command forms (or explicit prefix patterns) to avoid unintended execution.

Useful? React with 👍 / 👎.

&& github.event.issue.pull_request
&& (github.event.comment.author_association == 'OWNER'
|| github.event.comment.author_association == 'MEMBER') }}
runs-on: ubuntu-latest
steps:
- name: Add reaction
uses: peter-evans/create-or-update-comment@v4.0.0
with:
comment-id: ${{ github.event.comment.id }}
reactions: rocket
- name: Fast forwarding
uses: sequoia-pgp/fast-forward@v1.0.0
with:
merge: true
comment: always
github_token: ${{ secrets.GH_PUSH_TOKEN }}

rebase:
if: ${{ contains(github.event.comment.body, '/rebase')
&& github.event.issue.pull_request
&& (github.event.comment.author_association == 'OWNER'
|| github.event.comment.author_association == 'MEMBER') }}
runs-on: ubuntu-latest
steps:
- name: Add reaction
uses: peter-evans/create-or-update-comment@v4.0.0
with:
comment-id: ${{ github.event.comment.id }}
reactions: rocket
- name: Set git user
run: |
git config --global user.email "ci@fashionunited.com"
git config --global user.name "CI FashionUnited"
- name: Get pull request ref
id: get_pull_request_ref
uses: octokit/request-action@v2.4.0
with:
route: GET /repos/:repository/pulls/:issue_id
repository: ${{ github.repository }}
issue_id: ${{ github.event.issue.number }}
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ fromJSON(steps.get_pull_request_ref.outputs.data).head.ref }}
Comment on lines +59 to +61

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Check out PR head repository before rebasing

This checkout uses head.ref but leaves the repository implicit, so Actions clones github.repository (the base repo) rather than the PR head repo. For forked PRs this either fails when the branch name is missing, or worse, rebases and force-pushes a same-named branch in the base repository, which can rewrite the wrong branch when /rebase is run by a maintainer.

Useful? React with 👍 / 👎.

fetch-depth: 0
persist-credentials: false
token: ${{ secrets.GH_PUSH_TOKEN }}
- name: Set git credentials

Check failure on line 65 in .github/workflows/fast-forward.yml

View check run for this annotation

GitHub Advanced Security / CodeQL

Untrusted Checkout TOCTOU

Insufficient protection against execution of untrusted code on a privileged workflow ([issue_comment](1)).

Check failure on line 65 in .github/workflows/fast-forward.yml

View check run for this annotation

GitHub Advanced Security / CodeQL

Checkout of untrusted code in trusted context

Potential execution of untrusted code on a privileged workflow ([issue_comment](1))
Comment on lines +58 to +65

Check failure

Code scanning / CodeQL

Untrusted Checkout TOCTOU High

Insufficient protection against execution of untrusted code on a privileged workflow (
issue_comment
).
Comment on lines +58 to +65

Check failure

Code scanning / CodeQL

Checkout of untrusted code in trusted context High

Potential execution of untrusted code on a privileged workflow (
issue_comment
)
run: git remote set-url origin https://x-access-token:${{ secrets.GH_PUSH_TOKEN }}@github.com/${{ github.repository }}
- name: Fetch default branch
run: git fetch origin ${{ github.event.repository.default_branch }}
- name: Rebase branch on default branch
run: git rebase origin/${{ github.event.repository.default_branch }}
- name: Verify rebase success
run: |
if git status --porcelain | grep -q '^'; then
echo "Working directory is dirty after rebase"
exit 1
fi
- name: Force push to branch
run: git push --force-with-lease origin HEAD
Loading