Skip to content

Commit 4c775ba

Browse files
committed
Try fix Download appcast.xml error
1 parent f43cfd6 commit 4c775ba

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

.github/workflows/promote-release.yml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,19 +101,24 @@ jobs:
101101
const tagName = "${{ steps.get_latest_official_release.outputs.tag_name }}";
102102
const fs = require('fs');
103103
const path = require('path');
104+
// Get the release assets for the specified tag
105+
const { data: releaseData } = await github.rest.repos.getReleaseByTag({
106+
owner: context.repo.owner,
107+
repo: context.repo.repo,
108+
tag: tagName
109+
});
110+
const releaseId = releaseData.id;
104111
const { data: releaseAssets } = await github.rest.repos.listReleaseAssets({
105112
owner: context.repo.owner,
106113
repo: context.repo.repo,
107-
release_id: (await github.rest.repos.getReleaseByTag({
108-
owner: context.repo.owner,
109-
repo: context.repo.repo,
110-
tag: tagName
111-
})).data.id
114+
release_id: releaseId
112115
});
116+
// Look for the 'appcast.xml' asset
113117
const appcastAsset = releaseAssets.find(asset => asset.name === 'appcast.xml');
114118
if (!appcastAsset) {
115119
throw new Error('appcast.xml not found in the release assets.');
116120
}
121+
// Download the file content (as an ArrayBuffer)
117122
const { data: fileContent } = await github.rest.repos.getReleaseAsset({
118123
owner: context.repo.owner,
119124
repo: context.repo.repo,
@@ -122,9 +127,10 @@ jobs:
122127
Accept: 'application/octet-stream'
123128
}
124129
});
130+
// Convert ArrayBuffer -> Buffer, then write to disk
125131
const outputDir = path.join(process.env.GITHUB_WORKSPACE, 'dist', 'appcast');
126132
fs.mkdirSync(outputDir, { recursive: true });
127-
fs.writeFileSync(path.join(outputDir, 'appcast.xml'), fileContent);
133+
fs.writeFileSync(path.join(outputDir, 'appcast.xml'), Buffer.from(fileContent));
128134
console.log('appcast.xml downloaded successfully.');
129135
- name: Deploy to GitHub Pages
130136
uses: peaceiris/actions-gh-pages@v3

0 commit comments

Comments
 (0)