From 836adc44259a0836da9b1f671cc83d80f3418c90 Mon Sep 17 00:00:00 2001 From: "Joshua M. Boniface" Date: Thu, 18 Apr 2024 01:38:55 -0400 Subject: [PATCH] Add flock to openapi spec upload Prevents a race condition if two PRs are merged in very quick succession. --- .github/workflows/ci-openapi.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci-openapi.yml b/.github/workflows/ci-openapi.yml index bdbfcd3eb3..4a4d13c721 100644 --- a/.github/workflows/ci-openapi.yml +++ b/.github/workflows/ci-openapi.yml @@ -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