Skip to content

Queue Commits From Bevy Main #2355

Queue Commits From Bevy Main

Queue Commits From Bevy Main #2355

Workflow file for this run

name: Queue Commits From Bevy Main
on:
workflow_dispatch:
schedule:
- cron: "0 * * * *"
jobs:
queue-latest-commit:
name: Queue Latest Commit
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout Bevy main branch
uses: actions/checkout@v4
with:
repository: "bevyengine/bevy"
ref: "main"
- uses: actions/checkout@v4
with:
ref: "queue"
path: "queue"
- uses: actions/checkout@v4
with:
ref: "results"
path: "results"
- name: Queue latest commit
id: queue
run: |
gitref=`git rev-parse HEAD`
if ls queue/$gitref 1> /dev/null 2>&1
then
echo "commit already queued"
echo "ADDED=0" >> "$GITHUB_OUTPUT"
exit 0
fi
if find results/ | grep $gitref 1> /dev/null 2>&1
then
echo "commit already collected"
echo "ADDED=0" >> "$GITHUB_OUTPUT"
exit 0
fi
cd queue
touch $gitref
echo "ADDED=1" >> "$GITHUB_OUTPUT"
- name: Commit
if: steps.queue.outputs.ADDED > 0
run: |
cd queue
git config user.name 'Workflow'
git config user.email '<>'
git add .
git commit -m "Queued new commit"
git push
check-queue:
name: Check Queue
runs-on: ubuntu-latest
needs: [queue-latest-commit]
outputs:
queue_is_empty: ${{ steps.check_queue.outputs.QUEUE_IS_EMPTY }}
steps:
- uses: actions/checkout@v4
with:
ref: "queue"
- name: Check if queue is empty
id: check_queue
run: |
if [ `ls -1 | wc -l` -eq 0 ]; then
echo "Queue is empty"
echo "QUEUE_IS_EMPTY=true" >> "$GITHUB_OUTPUT"
else
echo "Queue is not empty"
echo "QUEUE_IS_EMPTY=false" >> "$GITHUB_OUTPUT"
fi
queue-history-commits:
needs: [check-queue]
if: needs.check-queue.outputs.queue_is_empty == 'true'
name: Queue History Commits
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout Bevy main branch
uses: actions/checkout@v4
with:
repository: "bevyengine/bevy"
ref: "main"
path: "bevy"
fetch-depth: 500
- uses: actions/checkout@v4
with:
ref: "queue"
path: "queue"
- uses: actions/checkout@v4
with:
ref: "results"
path: "results"
- name: Queue history commits
id: queue
run: |
cd bevy
i=0
j=0
max=3
for commit in `git log --no-abbrev-commit --pretty=oneline | sort | cut -d ' ' -f 1`
do
if find ../results/ | grep $commit 1> /dev/null 2>&1
then
:
else
j=$((j + 1))
if [ $i -lt $max ]; then
i=$((i + 1))
touch ../queue/$commit
fi
fi
done
echo "Added $i commits out of $j missing commits"
echo "ADDED=$i" >> "$GITHUB_OUTPUT"
echo "TOTAL=$j" >> "$GITHUB_OUTPUT"
- name: Commit
if: steps.queue.outputs.ADDED > 0
run: |
cd queue
git config user.name 'Workflow'
git config user.email '<>'
git add .
git commit -m "Queued ${{ steps.queue.outputs.ADDED }} / ${{ steps.queue.outputs.TOTAL }} history commits"
git push