mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-09-05 07:28:37 +08:00
fix(workflow): delete releases by tag (#728)
This commit is contained in:
@@ -70,40 +70,17 @@ jobs:
|
|||||||
> "$release_response" 2> "$release_error"
|
> "$release_response" 2> "$release_error"
|
||||||
set -e
|
set -e
|
||||||
release_status=$(awk 'NR == 1 { print $2; exit }' "$release_response")
|
release_status=$(awk 'NR == 1 { print $2; exit }' "$release_response")
|
||||||
release_id=""
|
|
||||||
|
|
||||||
if [ "$release_status" = "200" ]; then
|
if [ "$release_status" = "200" ]; then
|
||||||
release_id=$(awk 'body { print; exit } /^[[:space:]]*$/ { body=1 }' \
|
gh release delete "$TAG_NAME" \
|
||||||
"$release_response" | jq -r '.id')
|
--repo "$GITHUB_REPOSITORY" \
|
||||||
if [ -z "$release_id" ] || [ "$release_id" = "null" ]; then
|
--yes
|
||||||
echo "Unable to resolve release id for ${TAG_NAME}" >&2
|
|
||||||
cat "$release_error" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
elif [ "$release_status" != "404" ]; then
|
elif [ "$release_status" != "404" ]; then
|
||||||
echo "Unable to query release ${TAG_NAME} (HTTP ${release_status:-unknown})" >&2
|
echo "Unable to query release ${TAG_NAME} (HTTP ${release_status:-unknown})" >&2
|
||||||
cat "$release_error" >&2
|
cat "$release_error" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$release_id" ]; then
|
|
||||||
delete_response=$(mktemp)
|
|
||||||
delete_error=$(mktemp)
|
|
||||||
set +e
|
|
||||||
gh api --include --silent --method DELETE \
|
|
||||||
"repos/${GITHUB_REPOSITORY}/releases/${release_id}" \
|
|
||||||
> "$delete_response" 2> "$delete_error"
|
|
||||||
set -e
|
|
||||||
delete_status=$(awk 'NR == 1 { print $2; exit }' "$delete_response")
|
|
||||||
if [ "$delete_status" != "204" ] && [ "$delete_status" != "404" ]; then
|
|
||||||
echo "Unable to delete release ${TAG_NAME} (HTTP ${delete_status:-unknown})" >&2
|
|
||||||
cat "$delete_error" >&2
|
|
||||||
rm -f "$delete_response" "$delete_error"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
rm -f "$delete_response" "$delete_error"
|
|
||||||
fi
|
|
||||||
|
|
||||||
tag_query_response=$(mktemp)
|
tag_query_response=$(mktemp)
|
||||||
tag_query_error=$(mktemp)
|
tag_query_error=$(mktemp)
|
||||||
set +e
|
set +e
|
||||||
|
|||||||
@@ -72,13 +72,14 @@ describe('前端测试 workflow', () => {
|
|||||||
expect(workflow).toContain('run: yarn --frozen-lockfile')
|
expect(workflow).toContain('run: yarn --frozen-lockfile')
|
||||||
expect(workflow).toContain('echo "frontend_version=v$frontend_version"')
|
expect(workflow).toContain('echo "frontend_version=v$frontend_version"')
|
||||||
expect(workflow).toContain('gh api --include')
|
expect(workflow).toContain('gh api --include')
|
||||||
|
expect(workflow).toContain('gh release delete "$TAG_NAME"')
|
||||||
expect(workflow).toContain('gh release create "$TAG_NAME"')
|
expect(workflow).toContain('gh release create "$TAG_NAME"')
|
||||||
expect(workflow).toContain('release_status" != "404"')
|
expect(workflow).toContain('release_status" != "404"')
|
||||||
expect(workflow).toContain('delete_status" != "404"')
|
|
||||||
expect(workflow).toContain('git/ref/tags/${TAG_NAME}')
|
expect(workflow).toContain('git/ref/tags/${TAG_NAME}')
|
||||||
expect(workflow).toContain('tag_query_status" = "200"')
|
expect(workflow).toContain('tag_query_status" = "200"')
|
||||||
expect(workflow).toContain('tag_query_status" != "404"')
|
expect(workflow).toContain('tag_query_status" != "404"')
|
||||||
expect(workflow).toContain('tag_delete_status" != "204"')
|
expect(workflow).toContain('tag_delete_status" != "204"')
|
||||||
|
expect(workflow).not.toContain("awk 'body { print; exit }")
|
||||||
expect(workflow).not.toContain('dev-drprasad/delete-tag-and-release')
|
expect(workflow).not.toContain('dev-drprasad/delete-tag-and-release')
|
||||||
expect(workflow).not.toContain('softprops/action-gh-release')
|
expect(workflow).not.toContain('softprops/action-gh-release')
|
||||||
expect(workflow).not.toContain('actions/checkout@v3')
|
expect(workflow).not.toContain('actions/checkout@v3')
|
||||||
|
|||||||
Reference in New Issue
Block a user