openpilot/.github/workflows/schedule_update.yaml
2025-11-01 12:00:00 -07:00

74 lines
2.5 KiB
YAML

name: Schedule FrogPilot Update
on:
workflow_dispatch:
inputs:
scheduled_date:
description: "Enter the date to update the \"FrogPilot\" branch (YYYY-MM-DD)"
required: true
env:
BRANCH: FrogPilot-Staging
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
jobs:
schedule-update:
runs-on: ubuntu-latest
steps:
- name: Configure Git Identity
run: |
git config --global user.name "James"
git config --global user.email "91348155+FrogAi@users.noreply.github.com"
- name: Checkout ${{ env.BRANCH }}
uses: actions/checkout@v3
with:
persist-credentials: false
ref: ${{ env.BRANCH }}
fetch-depth: 3
- name: Schedule Update for ${{ github.event.inputs.scheduled_date }}
run: |
echo "${{ github.event.inputs.scheduled_date }}" > .github/update_date
git add .github/update_date
- name: Get Target Commit (Second Most Recent)
id: get_target
run: |
TARGET_COMMIT=$(git rev-parse HEAD~1)
AUTHOR_DATE=$(git show -s --format=%aD "$TARGET_COMMIT")
COMMITTER_DATE=$(git show -s --format=%cD "$TARGET_COMMIT")
echo "AUTHOR_DATE=$AUTHOR_DATE" >> $GITHUB_ENV
echo "COMMITTER_DATE=$COMMITTER_DATE" >> $GITHUB_ENV
echo "TARGET_COMMIT=$TARGET_COMMIT" >> $GITHUB_ENV
- name: Create Fixup Commit if Changes Exist
id: fixup_commit
run: |
if git diff --cached --quiet; then
echo "No changes to commit."
echo "has_changes=false" >> "$GITHUB_OUTPUT"
else
echo "Changes found, creating fixup commit."
git commit --fixup="${{ env.TARGET_COMMIT }}"
echo "has_changes=true" >> "$GITHUB_OUTPUT"
fi
- name: Autosquash Fixup into Target Commit
if: steps.fixup_commit.outputs.has_changes == 'true'
run: |
GIT_SEQUENCE_EDITOR=: git rebase --autosquash -i HEAD~3
- name: Restore Timestamps on Final Two Commits
if: steps.fixup_commit.outputs.has_changes == 'true'
run: |
git rebase --exec "GIT_COMMITTER_DATE='${{ env.COMMITTER_DATE }}' git commit --amend --no-edit --date='${{ env.AUTHOR_DATE }}'" HEAD~2
- name: Push Updated ${{ env.BRANCH }} Branch
if: steps.fixup_commit.outputs.has_changes == 'true'
run: |
git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }}
git push origin "${{ env.BRANCH }}" --force-with-lease