Skip to content

Commit 3b93c03

Browse files
Fix: Use ZipDeploy profile and verify publish output
1 parent 1153784 commit 3b93c03

1 file changed

Lines changed: 55 additions & 8 deletions

File tree

.github/workflows/master_uploadtriggerv2.yml

Lines changed: 55 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,58 @@ jobs:
3434
popd
3535
3636
- name: 'Deploy to Azure Function App'
37-
uses: Azure/functions-action@v1
38-
with:
39-
app-name: 'UploadTriggerV2'
40-
package: './Trigger/output'
41-
publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_V2 }}
42-
respect-funcignore: false
43-
scm-do-build-during-deployment: false
44-
enable-oryx-build: false
37+
shell: bash
38+
run: |
39+
python3 << 'EOF'
40+
import os
41+
import subprocess
42+
import xml.etree.ElementTree as ET
43+
44+
profile_xml = """${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_V2 }}"""
45+
root = ET.fromstring(profile_xml)
46+
47+
profile = None
48+
for p in root.findall('publishProfile'):
49+
if p.get('publishMethod') == 'ZipDeploy':
50+
profile = p
51+
break
52+
53+
if profile is None:
54+
raise SystemExit('ZipDeploy publish profile not found')
55+
56+
publish_url = profile.get('publishUrl')
57+
username = profile.get('userName')
58+
password = profile.get('userPWD')
59+
60+
deploy_url = publish_url
61+
if not deploy_url.startswith('https://'):
62+
deploy_url = f'https://{deploy_url}'
63+
deploy_url = f'{deploy_url}/api/zipdeploy'
64+
65+
output_dir = './Trigger/output'
66+
host_json = os.path.join(output_dir, 'host.json')
67+
if not os.path.exists(host_json):
68+
raise SystemExit('host.json not found in publish output')
69+
70+
zip_name = os.path.join(output_dir, 'output.zip')
71+
zip_result = subprocess.run(['zip', '-r', zip_name, '.'], cwd=output_dir)
72+
if zip_result.returncode != 0:
73+
raise SystemExit('zip failed')
74+
75+
curl_cmd = [
76+
'curl', '-sS', '-w', '%{http_code}', '-o', '/tmp/zipdeploy.out',
77+
'-X', 'POST', '-u', f'{username}:{password}',
78+
'-H', 'Content-Type: application/zip',
79+
'--data-binary', f'@{zip_name}', deploy_url
80+
]
81+
result = subprocess.run(curl_cmd, capture_output=True, text=True)
82+
http_code = (result.stdout or '').strip()
83+
print(f'ZipDeploy HTTP status: {http_code}')
84+
if http_code not in {'200', '201', '202'}:
85+
try:
86+
with open('/tmp/zipdeploy.out', 'r', encoding='utf-8') as fh:
87+
print(fh.read())
88+
except Exception:
89+
pass
90+
raise SystemExit('zipdeploy failed')
91+
EOF

0 commit comments

Comments
 (0)