mirror of https://github.com/jellyfin/jellyfin.git
ci: Add flock to openapi spec upload (#11381)
* Add flock to openapi spec upload
Prevents a race condition if two PRs are merged in very quick
succession.
* Remove lock at the end
* Revert "Remove lock at the end"
This reverts commit a7baafd10e
.
* Correct incorrect comments
* Exit with an error if flock fails
This commit is contained in:
parent
37d301ebd4
commit
7d67443aca
|
@ -174,6 +174,8 @@ jobs:
|
||||||
debug: false
|
debug: false
|
||||||
script_stop: false
|
script_stop: false
|
||||||
script: |
|
script: |
|
||||||
|
(
|
||||||
|
flock -x -w 300 200 || exit 1
|
||||||
TGT_DIR="/srv/repository/main/openapi"
|
TGT_DIR="/srv/repository/main/openapi"
|
||||||
LAST_SPEC="$( ls -lt ${TGT_DIR}/unstable/ | grep 'jellyfin-openapi' | head -1 | awk '{ print $NF }' )"
|
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
|
# If new and previous spec don't differ (diff retcode 0), remove incoming and finish
|
||||||
|
@ -187,10 +189,11 @@ jobs:
|
||||||
sudo rm ${TGT_DIR}/jellyfin-openapi-unstable_previous.json
|
sudo rm ${TGT_DIR}/jellyfin-openapi-unstable_previous.json
|
||||||
# Move current jellyfin-openapi-unstable.json symlink to jellyfin-openapi-unstable_previous.json
|
# Move current jellyfin-openapi-unstable.json symlink to jellyfin-openapi-unstable_previous.json
|
||||||
sudo mv ${TGT_DIR}/jellyfin-openapi-unstable.json ${TGT_DIR}/jellyfin-openapi-unstable_previous.json
|
sudo mv ${TGT_DIR}/jellyfin-openapi-unstable.json ${TGT_DIR}/jellyfin-openapi-unstable_previous.json
|
||||||
# Create new jellyfin-openapi-stable.json symlink
|
# Create new jellyfin-openapi-unstable.json symlink
|
||||||
sudo ln -s unstable/jellyfin-openapi-${{ env.JELLYFIN_VERSION }}.json ${TGT_DIR}/jellyfin-openapi-unstable.json
|
sudo ln -s unstable/jellyfin-openapi-${{ env.JELLYFIN_VERSION }}.json ${TGT_DIR}/jellyfin-openapi-unstable.json
|
||||||
# Check that the previous openapi spec is correct
|
# Check that the previous openapi unstable spec link is correct
|
||||||
if [[ "$( readlink ${TGT_DIR}/jellyfin-openapi-unstable_previous.json )" != "unstable/${LAST_SPEC}" ]]; then
|
if [[ "$( readlink ${TGT_DIR}/jellyfin-openapi-unstable_previous.json )" != "unstable/${LAST_SPEC}" ]]; then
|
||||||
sudo rm ${TGT_DIR}/jellyfin-openapi-unstable_previous.json
|
sudo rm ${TGT_DIR}/jellyfin-openapi-unstable_previous.json
|
||||||
sudo ln -s unstable/${LAST_SPEC} ${TGT_DIR}/jellyfin-openapi-unstable_previous.json
|
sudo ln -s unstable/${LAST_SPEC} ${TGT_DIR}/jellyfin-openapi-unstable_previous.json
|
||||||
fi
|
fi
|
||||||
|
) 200>/run/openapi-unstable.lock
|
||||||
|
|
Loading…
Reference in New Issue