Skip to content

Commit 8b101f0

Browse files
authored
Enhance beta build workflow with dynamic zip naming
This update introduces a step to determine the subfolder and zip name dynamically, modifies the artifact upload process to use the new zip name, and adjusts the dispatch to the beta repository to include the zip name.
1 parent 3324104 commit 8b101f0

1 file changed

Lines changed: 54 additions & 16 deletions

File tree

.github/workflows/send-beta-build.yml

Lines changed: 54 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,28 @@ jobs:
2323
runs-on: ubuntu-latest
2424
outputs:
2525
artifact-url: ${{ steps.get-artifact.outputs.url }}
26+
zip-name: ${{ steps.set-zip-name.outputs.zip_name }}
2627
steps:
2728
- name: Checkout source repo
2829
uses: actions/checkout@v4
2930
with:
3031
ref: updates
3132

33+
- name: Determine subfolder and zip name
34+
id: set-zip-name
35+
run: |
36+
# Use workflow_dispatch input if present; fall back to default
37+
SUBFOLDER="${{ github.event.inputs.subfolder || 'HTMLPlayerBeta' }}"
38+
39+
# Lowercase subfolder for zip name
40+
ZIP_NAME="$(echo "${SUBFOLDER}" | tr '[:upper:]' '[:lower:]')-build.zip"
41+
42+
echo "Subfolder: ${SUBFOLDER}"
43+
echo "Zip name: ${ZIP_NAME}"
44+
45+
echo "subfolder=${SUBFOLDER}" >> "$GITHUB_OUTPUT"
46+
echo "zip_name=${ZIP_NAME}" >> "$GITHUB_OUTPUT"
47+
3248
- name: Use Node.js
3349
uses: actions/setup-node@v4
3450
with:
@@ -43,43 +59,65 @@ jobs:
4359
run: npm run build
4460

4561
- name: Zip build artifacts
46-
run: zip -r htmlplayer-build.zip Build/dist
62+
run: |
63+
ZIP_NAME="${{ steps.set-zip-name.outputs.zip_name }}"
64+
echo "Creating zip: ${ZIP_NAME}"
65+
zip -r "${ZIP_NAME}" Build/dist
4766
4867
- name: Upload artifact
4968
uses: actions/upload-artifact@v4
5069
with:
51-
name: htmlplayer-build
52-
path: htmlplayer-build.zip
70+
# Use the dynamic zip name as the artifact name too
71+
name: ${{ steps.set-zip-name.outputs.zip_name }}
72+
path: ${{ steps.set-zip-name.outputs.zip_name }}
5373
retention-days: 1
5474

5575
- name: Get artifact download URL
5676
id: get-artifact
5777
uses: actions/github-script@v7
5878
with:
5979
script: |
80+
const zipName = process.env.ZIP_NAME;
81+
const { owner, repo } = context.repo;
82+
6083
const artifacts = await github.rest.actions.listWorkflowRunArtifacts({
61-
owner: context.repo.owner,
62-
repo: context.repo.repo,
84+
owner,
85+
repo,
6386
run_id: context.runId
6487
});
65-
const artifact = artifacts.data.artifacts.find(a => a.name === 'htmlplayer-build');
66-
if (!artifact) throw new Error('Artifact not found');
88+
89+
const artifact = artifacts.data.artifacts.find(a => a.name === zipName);
90+
if (!artifact) {
91+
core.setFailed(`Artifact with name ${zipName} not found`);
92+
return;
93+
}
94+
6795
core.setOutput('url', artifact.archive_download_url);
96+
env:
97+
ZIP_NAME: ${{ steps.set-zip-name.outputs.zip_name }}
6898

6999
- name: Dispatch to beta repo
70100
run: |
71-
SUBFOLDER="${{ github.event.inputs.subfolder || 'HTMLPlayerBeta' }}"
101+
SUBFOLDER="${{ steps.set-zip-name.outputs.subfolder }}"
72102
ARTIFACT_URL="${{ steps.get-artifact.outputs.url }}"
103+
ZIP_NAME="${{ steps.set-zip-name.outputs.zip_name }}"
104+
105+
echo "Dispatching with:"
106+
echo " subfolder: ${SUBFOLDER}"
107+
echo " artifact_url: ${ARTIFACT_URL}"
108+
echo " zip_name: ${ZIP_NAME}"
109+
73110
curl -X POST \
74111
-H "Authorization: token ${{ secrets.BETA_PAT_TOKEN }}" \
75112
-H "Accept: application/vnd.github+json" \
76113
https://api.github.com/repos/HTMLToolkit/beta/dispatches \
77-
-d '{
78-
"event_type": "deploy-build",
79-
"client_payload": {
80-
"source_repo": "'${{ github.repository }}'",
81-
"artifact_url": "'${ARTIFACT_URL}'",
82-
"token": "'${{ secrets.GITHUB_TOKEN }}'",
83-
"subfolder": "'${SUBFOLDER}'"
114+
-d "{
115+
\"event_type\": \"deploy-build\",
116+
\"client_payload\": {
117+
\"source_repo\": \"${{ github.repository }}\",
118+
\"artifact_url\": \"${ARTIFACT_URL}\",
119+
\"token\": \"${{ secrets.GITHUB_TOKEN }}\",
120+
\"subfolder\": \"${SUBFOLDER}\",
121+
\"zip_name\": \"${ZIP_NAME}\"
84122
}
85-
}'
123+
}"

0 commit comments

Comments
 (0)