Add flock to openapi spec upload

Prevents a race condition if two PRs are merged in very quick
succession.
This commit is contained in:
Joshua M. Boniface
2024-04-18 01:38:55 -04:00
parent 81d3758785
commit 836adc4425

View File

@@ -174,6 +174,8 @@ jobs:
debug: false
script_stop: false
script: |
(
flock -x -w 300 200
TGT_DIR="/srv/repository/main/openapi"
LAST_SPEC="$( ls -lt ${TGT_DIR}/unstable/ | grep 'jellyfin-openapi' | head -1 | awk '{ print $NF }' )"
# If new and previous spec don't differ (diff retcode 0), remove incoming and finish
@@ -194,3 +196,4 @@ jobs:
sudo rm ${TGT_DIR}/jellyfin-openapi-unstable_previous.json
sudo ln -s unstable/${LAST_SPEC} ${TGT_DIR}/jellyfin-openapi-unstable_previous.json
fi
) 200>/run/openapi-unstable.lock