Skip to content

Commit

Permalink
Improve Action Workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
oryx1729 committed Oct 16, 2024
1 parent 5300a2f commit 97a3db3
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 180 deletions.
62 changes: 28 additions & 34 deletions .github/workflows/deploy-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:

env:
DEEPSET_CLOUD_API_KEY: ${{ secrets.DEEPSET_CLOUD_API_KEY }}
DEEPSET_CLOUD_WORKSPACE_NAME: "your-dev-workspace-name"
DEEPSET_CLOUD_WORKSPACE_NAME: "YOUR_DEV_WORKSPACE_NAME"

jobs:
deploy:
Expand Down Expand Up @@ -71,54 +71,48 @@ jobs:
echo "Pipeline existence check status code: $pipeline_exists"
indexing_content=$(cat "$indexing_yaml")
query_content=$(cat "$query_yaml")
if [[ $pipeline_exists == "404" ]]; then
echo "Pipeline $pipeline_name doesn't exist. Creating new pipeline..."
indexing_content=$(cat "$indexing_yaml")
query_content=$(cat "$query_yaml")
combined_yaml=$(cat <<EOF
indexing:
$indexing_content
---
query:
$query_content
EOF
)
echo "Combined YAML for pipeline creation:"
echo "$combined_yaml"
payload=$(jq -n \
--arg name "$pipeline_name" \
--arg indexing "$indexing_content" \
--arg query "$query_content" \
'{
"name": $name,
"deepset_cloud_version": "v2",
"indexing_yaml": $indexing,
"query_yaml": $query
}')
response=$(curl --silent --show-error \
--write-out "\n%{http_code}" \
--request POST \
--url "https://api.cloud.deepset.ai/api/v1/workspaces/${DEEPSET_CLOUD_WORKSPACE_NAME}/pipelines" \
--header "Authorization: Bearer ${DEEPSET_CLOUD_API_KEY}" \
--header 'Content-Type: application/x-yaml' \
--data-binary "$combined_yaml")
--header 'Content-Type: application/json' \
--data "$payload")
else
echo "Pipeline $pipeline_name exists. Updating pipeline..."
indexing_content=$(cat "$indexing_yaml")
query_content=$(cat "$query_yaml")
combined_yaml=$(cat <<EOF
indexing:
$indexing_content
---
query:
$query_content
EOF
)
echo "Combined YAML for pipeline update:"
echo "$combined_yaml"
payload=$(jq -n \
--arg indexing "$indexing_content" \
--arg query "$query_content" \
'{
"indexing_yaml": $indexing,
"query_yaml": $query
}')
response=$(curl --silent --show-error \
--write-out "\n%{http_code}" \
--request PUT \
--url "https://api.cloud.deepset.ai/api/v1/workspaces/${DEEPSET_CLOUD_WORKSPACE_NAME}/pipelines/${pipeline_name}/yaml" \
--header "Authorization: Bearer ${DEEPSET_CLOUD_API_KEY}" \
--header 'Content-Type: application/x-yaml' \
--data-binary "$combined_yaml")
--header 'Content-Type: application/json' \
--data "$payload")
fi
status_code=$(echo "$response" | tail -n1)
Expand All @@ -133,7 +127,7 @@ jobs:
exit 1
fi
done
- name: Validate Pipelines
run: |
echo "Validating pipelines..."
Expand All @@ -151,7 +145,7 @@ jobs:
echo "Validation status code: $status_code"
echo "Validation response body: $response_body"
if [[ $status_code != "200" ]]; then
if [[ $status_code != "204" ]]; then
echo "Pipeline validation failed"
exit 1
fi
fi
60 changes: 27 additions & 33 deletions .github/workflows/deploy-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:

env:
DEEPSET_CLOUD_API_KEY: ${{ secrets.DEEPSET_CLOUD_API_KEY }}
DEEPSET_CLOUD_WORKSPACE_NAME: "your-prod-workspace-name"
DEEPSET_CLOUD_WORKSPACE_NAME: "YOUR_PROD_WORKSPACE_NAME"

jobs:
deploy:
Expand Down Expand Up @@ -72,54 +72,48 @@ jobs:
echo "Pipeline existence check status code: $pipeline_exists"
indexing_content=$(cat "$indexing_yaml")
query_content=$(cat "$query_yaml")
if [[ $pipeline_exists == "404" ]]; then
echo "Pipeline $pipeline_name doesn't exist. Creating new pipeline..."
indexing_content=$(cat "$indexing_yaml")
query_content=$(cat "$query_yaml")
combined_yaml=$(cat <<EOF
indexing:
$indexing_content
---
query:
$query_content
EOF
)
echo "Combined YAML for pipeline creation:"
echo "$combined_yaml"
payload=$(jq -n \
--arg name "$pipeline_name" \
--arg indexing "$indexing_content" \
--arg query "$query_content" \
'{
"name": $name,
"deepset_cloud_version": "v2",
"indexing_yaml": $indexing,
"query_yaml": $query
}')
response=$(curl --silent --show-error \
--write-out "\n%{http_code}" \
--request POST \
--url "https://api.cloud.deepset.ai/api/v1/workspaces/${DEEPSET_CLOUD_WORKSPACE_NAME}/pipelines" \
--header "Authorization: Bearer ${DEEPSET_CLOUD_API_KEY}" \
--header 'Content-Type: application/x-yaml' \
--data-binary "$combined_yaml")
--header 'Content-Type: application/json' \
--data "$payload")
else
echo "Pipeline $pipeline_name exists. Updating pipeline..."
indexing_content=$(cat "$indexing_yaml")
query_content=$(cat "$query_yaml")
combined_yaml=$(cat <<EOF
indexing:
$indexing_content
---
query:
$query_content
EOF
)
echo "Combined YAML for pipeline update:"
echo "$combined_yaml"
payload=$(jq -n \
--arg indexing "$indexing_content" \
--arg query "$query_content" \
'{
"indexing_yaml": $indexing,
"query_yaml": $query
}')
response=$(curl --silent --show-error \
--write-out "\n%{http_code}" \
--request PUT \
--url "https://api.cloud.deepset.ai/api/v1/workspaces/${DEEPSET_CLOUD_WORKSPACE_NAME}/pipelines/${pipeline_name}/yaml" \
--header "Authorization: Bearer ${DEEPSET_CLOUD_API_KEY}" \
--header 'Content-Type: application/x-yaml' \
--data-binary "$combined_yaml")
--header 'Content-Type: application/json' \
--data "$payload")
fi
status_code=$(echo "$response" | tail -n1)
Expand Down Expand Up @@ -152,15 +146,15 @@ jobs:
echo "Validation status code: $status_code"
echo "Validation response body: $response_body"
if [[ $status_code != "200" ]]; then
if [[ $status_code != "204" ]]; then
echo "Pipeline validation failed"
exit 1
fi
- name: Deploy Pipelines to Prod Workspace
env:
DEEPSET_CLOUD_API_KEY: ${{ secrets.DEEPSET_CLOUD_API_KEY }}
DEEPSET_CLOUD_WORKSPACE_NAME: "your-prod-workspace-name"
DEEPSET_CLOUD_WORKSPACE_NAME: "YOUR_PROD_WORKSPACE_NAME"
run: |
for pipeline in pipelines/*.yaml; do
deepset-cloud pipelines upload \
Expand Down
Loading

0 comments on commit 97a3db3

Please sign in to comment.