-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1248bd5
commit 09e2a1a
Showing
11 changed files
with
765 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
name: Get Deployment Bundle Info | ||
description: Get deployment bundle info from Astronomer API | ||
inputs: | ||
deployment_id: | ||
description: The deployment ID | ||
required: true | ||
organization_id: | ||
description: The organization ID | ||
required: true | ||
astro_api_token: | ||
description: The Astronomer API token | ||
required: true | ||
astronomer_host: | ||
description: The Astronomer host | ||
required: true | ||
expected_status_code: | ||
description: The expected status code | ||
default: 200 | ||
|
||
outputs: | ||
desired_bundle_version: | ||
description: The desired bundle version | ||
value: ${{ steps.get-deployment-info.outputs.desired_bundle_version }} | ||
bundle_type: | ||
description: The bundle type | ||
value: ${{ steps.get-deployment-info.outputs.bundle_type }} | ||
updated_at: | ||
description: The timestamp at which the bundle was last updated | ||
value: ${{ steps.get-deployment-info.outputs.updated_at }} | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Get Deployment Info | ||
id: get-deployment-info | ||
shell: bash | ||
run: | | ||
STATUS_CODE=$(curl -s -w "%{http_code}" -o response.json -H "Authorization: Bearer ${{ inputs.astro_api_token }}" "https://api.${{ inputs.astronomer_host }}/v1alpha1/organizations/${{ inputs.organization_id }}/deployments/${{ inputs.deployment_id }}/deploys") | ||
if [[ $STATUS_CODE -ne ${{ inputs.expected_status_code }} ]]; then | ||
echo "Failed to get expected status code from GET Deployment API. Status code: $STATUS_CODE" | ||
exit 1 | ||
fi | ||
if [[ $(cat response.json | jq -r '.deploys | length') -eq 0 ]]; then | ||
echo "No deploys found for the deployment: ${{ inputs.deployment_id }}" | ||
exit 1 | ||
fi | ||
# sort by updatedAt to fetch the latest deploy object | ||
cat response.json | jq '.deploys | sort_by(.updatedAt)' > response_sorted.json | ||
desired_bundle_version=$(cat response_sorted.json | jq -r '.[] | select(.type == "BUNDLE" and .bundles[0].bundleType == "dbt") | .bundles[0].desiredVersion' | head -n 1) | ||
bundle_type=$(cat response_sorted.json | jq -r '.[] | select(.type == "BUNDLE" and .bundles[0].bundleType == "dbt") | .bundles[0].bundleType' | head -n 1) | ||
updated_at=$(cat response_sorted.json | jq -r '.[] | select(.type == "BUNDLE" and .bundles[0].bundleType == "dbt") | .updatedAt' | head -n 1) | ||
echo "desired_bundle_version=$desired_bundle_version" >> $GITHUB_OUTPUT | ||
echo "bundle_type=$bundle_type" >> $GITHUB_OUTPUT | ||
echo "updated_at=$updated_at" >> $GITHUB_OUTPUT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.