Skip to content

Add aruco_ros (not on Windows) #195

Add aruco_ros (not on Windows)

Add aruco_ros (not on Windows) #195

Workflow file for this run

name: Auto-merge

Check warning on line 1 in .github/workflows/automerge.yaml

View workflow run for this annotation

GitHub Actions / Auto-merge

Workflow execution policy warning (evaluate mode)

On November 2, 2026, GitHub will restrict `pull_request_target` on public repositories by default. To continue allowing the event trigger, configure an Actions policy. Learn more: https://gh.io/securely-using-pull_request_target#default-policy-for-pull_request_target
# Adding the "automerge" label to a pull request turns on GitHub's auto-merge: the
# pull request is merged as soon as the required checks ("All green") pass.
# Removing the label turns it off again. Pull requests without the label are never
# merged automatically. New commits pushed after the label was added remove it (and
# turn auto-merge off), so what gets merged is always what was looked at.
#
# pull_request_target so that the token can merge pull requests from forks too; the
# pull request's code is never checked out or run here.
on:
pull_request_target:
types: [labeled, unlabeled, synchronize]
permissions:
contents: write
pull-requests: write
jobs:
automerge:
if: github.event.action != 'synchronize' && github.event.label.name == 'automerge'
concurrency:
group: automerge-${{ github.event.pull_request.number }}
cancel-in-progress: false
runs-on: ubuntu-latest
steps:
# the base branch (pull_request_target's default), for pixi's gh: never the pull request's code
- uses: actions/checkout@v6
with:
persist-credentials: false
- name: Disable git auto-maintenance
run: git config --global maintenance.auto false && git config --global gc.auto 0
- uses: prefix-dev/setup-pixi@v0.11.0
with:
locked: true # the lock file must match pixi.toml
pixi-version: v0.81.0
cache-write: false # saved from main only (pixi-cache.yaml)
# The merge has to come from the bot (or a PAT): a merge made with the
# workflow's own token would not trigger the main build workflow.
- name: Bot token
id: app
if: vars.ROBOSTACK_BOT_CLIENT_ID != ''
uses: actions/create-github-app-token@v3
with:
client-id: ${{ vars.ROBOSTACK_BOT_CLIENT_ID }}
private-key: ${{ secrets.ROBOSTACK_BOT_PRIVATE_KEY }}
- name: Turn auto-merge on or off
env:
GH_TOKEN: ${{ steps.app.outputs.token || secrets.GHA_PAT || github.token }}
BOT_TOKEN: ${{ steps.app.outputs.token || secrets.GHA_PAT }}
PR: ${{ github.event.pull_request.html_url }}
run: |
# labeled/unlabeled events can arrive out of order: go by the label the
# pull request has now, not by the event
enabled=$(pixi run gh pr view "$PR" --json labels --jq 'any(.labels[]; .name == "automerge")')
if [ "$enabled" = true ]; then
if [ -z "$BOT_TOKEN" ]; then
echo "::error::auto-merge needs the bot app (ROBOSTACK_BOT_CLIENT_ID + ROBOSTACK_BOT_PRIVATE_KEY) or GHA_PAT: a merge with the workflow token doesn't start the build workflow"
exit 1
fi
GH_TOKEN="$BOT_TOKEN" pixi run gh pr merge "$PR" --auto --merge
else
pixi run gh pr merge "$PR" --disable-auto
fi
drop-on-push:
if: >-
github.event.action == 'synchronize' &&
contains(github.event.pull_request.labels.*.name, 'automerge')
concurrency:
group: automerge-${{ github.event.pull_request.number }}
cancel-in-progress: false
runs-on: ubuntu-latest
steps:
# the base branch (pull_request_target's default), for pixi's gh: never the pull request's code
- uses: actions/checkout@v6
with:
persist-credentials: false
- name: Disable git auto-maintenance
run: git config --global maintenance.auto false && git config --global gc.auto 0
- uses: prefix-dev/setup-pixi@v0.11.0
with:
locked: true # the lock file must match pixi.toml
pixi-version: v0.81.0
cache-write: false # saved from main only (pixi-cache.yaml)
# removing the label with this token doesn't start the unlabeled run above, so
# turn auto-merge off here as well
- name: Remove the automerge label
env:
GH_TOKEN: ${{ github.token }}
PR: ${{ github.event.pull_request.html_url }}
BEFORE: ${{ github.event.before }}
AFTER: ${{ github.event.after }}
run: |
pixi run gh pr edit "$PR" --remove-label automerge
pixi run gh pr merge "$PR" --disable-auto || true
pixi run gh pr comment "$PR" --body "New commits (${BEFORE:0:7}..${AFTER:0:7}) arrived after the \`automerge\` label was added, so the label was removed and auto-merge turned off. Add the label again once the new commits are reviewed."