mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-11-26 01:00:36 +08:00
ci(px4_msgs): create the release branch when PX4 creates one
The px4_msgs sync only runs when msg/ or srv/ change, so a new PX4 release branch gets no px4_msgs branch until the first message change lands on it. For release/1.18 the branch was pushed by hand. Let sync_to_px4_msgs.yml be called with a branch name, and call it from the workflow that already runs when a release branch is created. The dispatch to px4-ros2-interface-lib now waits for it, so the px4_msgs branch exists by the time the library creates its own. The dispatch goes through gh api instead of curl -s -f, which hid the HTTP status when the request was refused for release/1.18. Assisted-by: Claude:claude-fable-5-2 Signed-off-by: Ramon Roche <mrpollo@gmail.com>
This commit is contained in:
1 parent
fdbc999ed8
commit
fb6829085a
2 files changed
+35
-26
No files matched your search
@@ -1,4 +1,4 @@
|
||||
name: Sync release branch to px4-ros2-interface-lib
|
||||
name: Sync release branch to px4_msgs and px4-ros2-interface-lib
|
||||
|
||||
on:
|
||||
create:
|
||||
@@ -12,32 +12,32 @@ on:
|
||||
permissions: {}
|
||||
|
||||
jobs:
|
||||
notify-interface-lib:
|
||||
# px4_msgs goes first, so its release branch already exists when the
|
||||
# interface library is told to create the branch that builds against it.
|
||||
sync-px4-msgs:
|
||||
if: >-
|
||||
github.repository == 'PX4/PX4-Autopilot' &&
|
||||
(
|
||||
(github.event_name == 'create' && github.ref_type == 'branch' && startsWith(github.ref_name, 'release/')) ||
|
||||
github.event_name == 'workflow_dispatch'
|
||||
)
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Determine branch name
|
||||
id: params
|
||||
run: |
|
||||
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
|
||||
BRANCH="${{ inputs.branch }}"
|
||||
else
|
||||
BRANCH="${{ github.ref_name }}"
|
||||
fi
|
||||
echo "branch=$BRANCH" >> "$GITHUB_OUTPUT"
|
||||
echo "Dispatching for branch: $BRANCH"
|
||||
permissions:
|
||||
contents: read
|
||||
uses: ./.github/workflows/sync_to_px4_msgs.yml
|
||||
with:
|
||||
branch: ${{ inputs.branch || github.ref_name }}
|
||||
secrets: inherit
|
||||
|
||||
notify-interface-lib:
|
||||
needs: sync-px4-msgs
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.PX4BUILTBOT_PERSONAL_ACCESS_TOKEN }}
|
||||
BRANCH: ${{ inputs.branch || github.ref_name }}
|
||||
steps:
|
||||
# gh prints the HTTP status and GitHub's message when the dispatch is refused
|
||||
- name: Dispatch release branch creation
|
||||
run: |
|
||||
BRANCH="${{ steps.params.outputs.branch }}"
|
||||
curl -s -f -X POST \
|
||||
-H "Authorization: token ${{ secrets.PX4BUILTBOT_PERSONAL_ACCESS_TOKEN }}" \
|
||||
-H "Accept: application/vnd.github.v3+json" \
|
||||
https://api.github.com/repos/Auterion/px4-ros2-interface-lib/dispatches \
|
||||
-d "{\"event_type\":\"px4_release_branch\",\"client_payload\":{\"branch\":\"$BRANCH\"}}"
|
||||
echo "Dispatched px4_release_branch event for $BRANCH"
|
||||
run: >-
|
||||
gh api repos/Auterion/px4-ros2-interface-lib/dispatches
|
||||
-f event_type=px4_release_branch
|
||||
-f "client_payload[branch]=$BRANCH"
|
||||
@@ -9,6 +9,12 @@ on:
|
||||
paths:
|
||||
- 'msg/**'
|
||||
- 'srv/**'
|
||||
workflow_call:
|
||||
inputs:
|
||||
branch:
|
||||
description: 'PX4 branch to sync (default: the ref the workflow runs on)'
|
||||
required: false
|
||||
type: string
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
@@ -21,9 +27,12 @@ jobs:
|
||||
env:
|
||||
# read by gh's git credential helper at push time
|
||||
GH_TOKEN: ${{ secrets.PX4BUILTBOT_PERSONAL_ACCESS_TOKEN }}
|
||||
BRANCH: ${{ inputs.branch || github.ref_name }}
|
||||
steps:
|
||||
- name: Checkout PX4 repo
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
ref: ${{ inputs.branch }}
|
||||
|
||||
- name: Setup git credentials
|
||||
run: |
|
||||
@@ -42,10 +51,10 @@ jobs:
|
||||
- name: Check out the same branch as the PX4 repo
|
||||
run: |
|
||||
cd px4_msgs
|
||||
if git checkout ${{ github.ref_name }}; then
|
||||
if git checkout "$BRANCH"; then
|
||||
echo "Checked out existing branch"
|
||||
else
|
||||
git checkout -b ${{ github.ref_name }}
|
||||
git checkout -b "$BRANCH"
|
||||
fi
|
||||
|
||||
- name: Copy ROS 2 messages
|
||||
@@ -72,9 +81,9 @@ jobs:
|
||||
if git diff --cached --quiet; then
|
||||
echo "No message changes to commit"
|
||||
else
|
||||
git commit -m "Update to PX4 ${{ github.sha }}"
|
||||
git commit -m "Update to PX4 $(git -C .. rev-parse HEAD)"
|
||||
fi
|
||||
# push even without a new commit, so a bad token or a new branch never goes unnoticed
|
||||
git push origin ${{ github.ref_name }}
|
||||
git push origin "$BRANCH"
|
||||
cd ..
|
||||
rm -rf px4_msgs
|
||||
Reference in new issue
Block a user