Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: CD PAT #233

Closed
wants to merge 10 commits into from
Closed
Prev Previous commit
Next Next commit
fix: remove -rc
skylar-simoncelli authored Nov 14, 2024
commit dce96255c4b534827030d88a5c8e9dc299d7b4c1
44 changes: 12 additions & 32 deletions .github/actions/release/publish-draft-release/action.yml
Original file line number Diff line number Diff line change
@@ -23,9 +23,7 @@ runs:
tag="${{ inputs.tag }}"
release_response=$(curl -s -H "Authorization: token ${{ env.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/releases?per_page=100")

release_id=$(echo "$release_response" | jq -r '.[] | select(.tag_name=="'"$tag"'") | .id')

if [ -z "$release_id" ] || [ "$release_id" == "null" ]; then
echo "release_exists=false" >> "$GITHUB_OUTPUT"
echo "release_id=" >> "$GITHUB_OUTPUT"
@@ -40,45 +38,27 @@ runs:
set -e
if [[ "${{ steps.check_release.outputs.release_exists }}" == "true" ]]; then
release_id="${{ steps.check_release.outputs.release_id }}"

# Set draft to false
release_data=$(curl -s -H "Authorization: token ${{ env.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/releases/$release_id")
current_body=$(echo "$release_data" | jq -r .body)
updated_body=$(echo "$current_body" | \
sed 's/- \[ \] Staging preview environment/- [x] Staging preview environment/g' | \
sed 's/This is a draft pre-release candidate/This is a pre-release candidate/g')
json_data=$(jq -n \
--arg name "$tag" \
--arg body "$updated_body" \
'{"draft": false, "name": $name, "body": $body}')
response=$(curl -s -X PATCH -H "Authorization: token ${{ env.GITHUB_TOKEN }}" \
-d '{"draft": false}' \
-d "$json_data" \
"https://api.github.com/repos/${{ github.repository }}/releases/$release_id")

echo "Response: $response"

# Verify the release was updated
if echo "$response" | jq -e '.id' >/dev/null; then
echo "Release updated successfully"
else
echo "Failed to update release"
exit 1
fi

# Extract the current release body
current_body=$(echo "$response" | jq -r .body)

# Perform the desired replacements
updated_body=$(echo "$current_body" | \
sed 's/- \[ \] Staging preview environment/- [x] Staging preview environment/g' | \
sed 's/This is a draft pre-release/This is a pre-release/g')

# Update the release body with the modified content
updated_response=$(curl -s -X PATCH -H "Authorization: token ${{ env.GITHUB_TOKEN }}" \
-d '{"body": "'"$updated_body"'"}' \
"https://api.github.com/repos/${{ github.repository }}/releases/$release_id")

echo "Body Update Response: $updated_response"

# Verify the release body was updated
if echo "$updated_response" | jq -e '.body' >/dev/null; then
echo "Release body updated successfully"
else
echo "Failed to update release body"
exit 1
fi
else
echo "Release does not exist, skipping publish step."
fi
shell: bash
shell: bash