diff --git a/lib/vault.sh b/lib/vault.sh index ed42ffc..3281a71 100644 --- a/lib/vault.sh +++ b/lib/vault.sh @@ -158,6 +158,19 @@ before execution. See the TOML file for details." local file_path="vault/actions/${action_id}.toml" _vault_log "Writing ${file_path} to branch ${branch}" + # Get current file content if exists (for upload API) + local current_content="" + local file_exists + file_exists=$(curl -sf -s -o /dev/null -w "%{http_code}" \ + -H "Authorization: token ${FORGE_TOKEN}" \ + "${ops_api}/contents/${file_path}?ref=${branch}" 2>/dev/null || echo "0") + + if [ "$file_exists" = "200" ]; then + current_content=$(curl -sf -H "Authorization: token ${FORGE_TOKEN}" \ + "${ops_api}/contents/${file_path}?ref=${branch}" 2>/dev/null | \ + jq -r '.content // empty') + fi + # Encode TOML content as base64 local encoded_content encoded_content=$(printf '%s' "$toml_content" | base64 -w 0)