@@ -33,8 +33,6 @@ if test -z "$CONFIDENCE_ACCOUNT_ID"; then
3333fi
3434
3535if test -z " $CONFIDENCE_RESOLVER_STATE_URL " ; then
36- echo " CONFIDENCE_RESOLVER_STATE_URL not provided; attempting to fetch via API"
37-
3836 # Ensure jq is available for JSON parsing
3937 if ! command -v jq > /dev/null 2>&1 ; then
4038 echo " jq is required but not installed. Please install jq (e.g., brew install jq) or provide CONFIDENCE_RESOLVER_STATE_URL"
@@ -101,10 +99,6 @@ if test -z "$CONFIDENCE_RESOLVER_STATE_URL"; then
10199 fi
102100fi
103101
104- echo " Starting CloudFlare deployment for $CONFIDENCE_ACCOUNT_ID "
105- echo " CloudFlare API token: ${CLOUDFLARE_API_TOKEN: 0: 5} .."
106- echo " CloudFlare account ID: $CLOUDFLARE_ACCOUNT_ID "
107-
108102mkdir -p data
109103RESPONSE_FILE=" data/resolver_state_current.pb"
110104ETAG_TOML=" "
@@ -115,21 +109,21 @@ CLIENT_SECRET_TOML=""
115109
116110EXTRA_HEADER=()
117111
118- # Try to fetch previous ETag from deployed resolver endpoint if provided
112+ # Try to fetch previous etag from deployed resolver endpoint if provided
119113PREV_ETAG=" "
120114PREV_DEPLOYER_VERSION=" "
121115if [ -n " $CONFIDENCE_RESOLVER_STATE_ETAG_URL " ]; then
122- echo " 🌐 Fetching previous ETag from $CONFIDENCE_RESOLVER_STATE_ETAG_URL "
116+ echo " 🌐 Fetching etag and git version from $CONFIDENCE_RESOLVER_STATE_ETAG_URL "
123117 ETAG_BODY_TMP=$( mktemp)
124118 ETAG_STATUS=$( curl -sS -w " %{http_code}" -o " $ETAG_BODY_TMP " " $CONFIDENCE_RESOLVER_STATE_ETAG_URL " ) || ETAG_STATUS=" 000"
125119 if [ " $ETAG_STATUS " = " 200" ]; then
126120 if command -v jq > /dev/null 2>&1 && grep -q ' ^[[:space:]]*{' " $ETAG_BODY_TMP " ; then
127121 PREV_ETAG=$( jq -r ' .etag // empty' " $ETAG_BODY_TMP " ) || PREV_ETAG=" "
128122 PREV_DEPLOYER_VERSION=$( jq -r ' .version // empty' " $ETAG_BODY_TMP " ) || PREV_DEPLOYER_VERSION=" "
129123 if [ -n " $PREV_ETAG " ]; then
130- echo " ⤵️ Previous ETag from resolver: $PREV_ETAG "
124+ echo " ⤵️ Previous etag from resolver: $PREV_ETAG "
131125 else
132- echo " ⚠️Resolver returned empty ETag"
126+ echo " ⚠️ Resolver returned empty ETag"
133127 fi
134128 if [ -n " $PREV_DEPLOYER_VERSION " ]; then
135129 echo " ⤵️ Previous Resolver Version from resolver: $PREV_DEPLOYER_VERSION "
@@ -140,13 +134,13 @@ if [ -n "$CONFIDENCE_RESOLVER_STATE_ETAG_URL" ]; then
140134 PREV_ETAG=$( tr -d ' \r' < " $ETAG_BODY_TMP " )
141135 PREV_ETAG=$( echo -n " $PREV_ETAG " | tr -d ' \n' )
142136 if [ -n " $PREV_ETAG " ]; then
143- echo " ⤵️ Previous ETag from resolver: $PREV_ETAG "
137+ echo " ⤵️ Previous etag from resolver: $PREV_ETAG "
144138 else
145139 echo " ⚠️ Resolver returned empty ETag"
146140 fi
147141 fi
148142 else
149- echo " ❌ Could not fetch ETag from resolver (HTTP $ETAG_STATUS )"
143+ echo " ❌ Could not fetch etag from resolver (HTTP $ETAG_STATUS )"
150144 fi
151145 rm -f " $ETAG_BODY_TMP "
152146fi
167161fi
168162
169163
170- # If version changed, force download to bypass ETag and ensure fresh deploy
164+ # If version changed, force download to bypass etag and ensure fresh deploy
171165if [ -n " $PREV_DEPLOYER_VERSION " ] && [ -n " $DEPLOYER_VERSION " ] && [ " $PREV_DEPLOYER_VERSION " != " $DEPLOYER_VERSION " ]; then
172166 echo " ☑️ Deployer version changed ($PREV_DEPLOYER_VERSION -> $DEPLOYER_VERSION ); forcing state download and redeploy"
173167 FORCE_DEPLOY=1
@@ -192,7 +186,7 @@ if [ "$HTTP_STATUS" = "304" ]; then
192186 exit 0
193187elif [ " $HTTP_STATUS " = " 200" ]; then
194188 echo " ✅ Download of resolver state successful"
195- # Extract ETag and normalize
189+ # Extract etag and normalize
196190 ETAG_RAW=$( awk -F' : ' ' tolower($1)=="etag"{print $2}' " $TMP_HEADER " | tr -d ' \r' )
197191 rm -f " $TMP_HEADER "
198192 # Normalize ETag: drop weak prefix and surrounding quotes, then escape for TOML
@@ -235,14 +229,18 @@ echo "🚀 All files successfully created and verified"
235229
236230cd confidence-cloudflare-resolver
237231
232+ echo " 🏁 Starting CloudFlare deployment for $CONFIDENCE_ACCOUNT_ID "
233+ echo " ☁️ CloudFlare API token: ${CLOUDFLARE_API_TOKEN: 0: 5} .."
234+ echo " ☁️ CloudFlare account ID: $CLOUDFLARE_ACCOUNT_ID "
235+
236+
238237if [ -n " $CLOUDFLARE_ACCOUNT_ID " ]; then
239238 # Remove existing account_id line if present
240239 sed -i.tmp ' /^account_id *= *.*$/d' wrangler.toml
241240 tmpfile=$( mktemp)
242241 echo " account_id = \" $CLOUDFLARE_ACCOUNT_ID \" " > " $tmpfile "
243242 cat wrangler.toml >> " $tmpfile "
244243 mv " $tmpfile " wrangler.toml
245- echo " ✅ account_id set to \" $CLOUDFLARE_ACCOUNT_ID \" in wrangler.toml"
246244else
247245 echo " ⚠️ CLOUDFLARE_ACCOUNT_ID environment variable is not set. This is required if the CloudFlare API token is of type Account, while User tokens with the correct permissions don't need this env variable set"
248246fi
0 commit comments