Skip to content

Commit

Permalink
Action to renumber objects
Browse files Browse the repository at this point in the history
The action will renumber objects with ID greater than nextObjectNumber, and set nextObjectNumber.txt to the max ID post-renumbering.

Note that the original node script from CCM has the following arguments:
RenumberObjects.js <start_number> <offset?> <end_number?>

This action determines start_number automatically as the smallest ID larger than nextObjectNumber.
Run RenumberObjects.js nextObjectNumber.
(At this point the script changes nextObjectNumber.txt back to start_number. It does this because of CCM's workflow.)
That's why the action then set nextObjectNumber.txt to max ID.
  • Loading branch information
risvh committed Mar 24, 2024
1 parent f1b85e6 commit a6a1403
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions .github/workflows/renumber-objects.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,34 @@ name: Renumber objects

on:
workflow_dispatch:
inputs:
start:
type: number
required: true
offset:
type: number
end:
type: number

jobs:
renumber:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Checkout merged PR
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}

- uses: actions/setup-node@v4
with:
node-version: 18

- run: node RenumberObjects.js ${{ inputs.start }} ${{ inputs.offset }} ${{ inputs.end }}
- run: |
nextID=$( cat objects/nextObjectNumber.txt )
maxID=$(ls -v objects/[0-9]* | tail -1 | sed 's/objects\///' | sed 's/.txt//')
start_number=$maxID
for fn in objects/[0-9]*.txt; do
id="${fn//[^0-9]/}"
(( id > nextID && id < start_number )) && start_number=$id
done
node RenumberObjects.js $start_number
maxID=$(ls -v objects/[0-9]* | tail -1 | sed 's/objects\///' | sed 's/.txt//')
echo -n $((maxID + 1)) > objects/nextObjectNumber.txt
# - uses: EndBug/add-and-commit@v9
# with:
# message: "Renumber objects"
# default_author: github-actions
- uses: EndBug/add-and-commit@v9
with:
message: "Renumber objects"
default_author: github_actions

0 comments on commit a6a1403

Please sign in to comment.