-
Notifications
You must be signed in to change notification settings - Fork 189
use wildcards in asset_path #47
Comments
In a similar fashion (possible exactly the same scenario as OP) I have an asset with a version appended to the filename. It would be easier to use a wildcard in place of grabbing the version. |
Hi @konradpabjan thanks on your recent v2 on your artifact actions. Would it be possible for you to use some of the code from https://github.com/actions/upload-artifact to this repo too? softprops/action-gh-release is a common alternative but I think the official version could use some love |
Hi @publicarray the v2 upload artifact action uses @actions/glob to handle wildcard search behind the scenes to handle wildcards. It should be possible to easily use this with any other actions. Upload releases is not my cup of tea unfortunately and I haven't worked with this action before. I can try to ping the necessary parties to see if this could maybe get some love. |
Hey @konradpabjan, |
@derTobsch, meanwhile, eine/tip might work for you. See actions/upload-artifact#21 (comment) |
This isn't entirely what was asked, and I still think support for wildcards is needed, but I wanted to point folks in the direction of I had the same issue of wanting to upload artifacts where the names are dynamic, and solved it with this action: - name: Create Release
uses: actions/github-script@v2
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
console.log('environment', process.versions);
const fs = require('fs').promises;
const { repo: { owner, repo }, sha } = context;
console.log({ owner, repo, sha });
const release = await github.repos.createRelease({
owner, repo,
tag_name: process.env.GITHUB_REF,
draft: true,
target_commitish: sha
});
console.log('created release', { release });
for (let file of await fs.readdir('.')) {
// do whatever filtering you want here, I'm just uploading all the files
console.log('uploading', file);
await github.repos.uploadReleaseAsset({
owner, repo,
release_id: release.data.id,
name: file,
data: await fs.readFile(`./${file}`)
});
} |
@catdad does github-scripts allow defining arbitrary npm packages as dependencies or is it limited to a fixed set? |
@eine Best I can tell, no dependencies are available by default, but you can install anything you want in a previous step of the same job. |
as a workaround can this work?
|
I solved my problem with this workaround, I save the filename to the step output, and then retrieve it in a later stage. For this I had to add an ID to my step as shown below.
|
One bug I found with this solution is when referring to needs/steps within the async/await functions and loops, you get an error This can be fixed by adding the values needs to variables within the script scope. For example: - name: Upload
uses: actions/github-script@v3
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const path = require('path');
const fs = require('fs');
const release_id = '${{ needs.create_release.outputs.id }}';
for (let file of await fs.readdirSync('./')) {
if (path.extname(file) === '.zip') {
console.log('uploadReleaseAsset', file);
await github.repos.uploadReleaseAsset({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: release_id,
name: file,
data: await fs.readFileSync(`./${file}`)
});
}
} |
Hi
Im trying to use the action, and looks like i can't use wildcards.
i would like to do is upload any *.whl file in that dist folder using this:
asset_path: dist/*.whl
But i have an error as the file is not found. Looks like I need to specify the asset_path with the full name:
asset_path: dist/whatthefuzz-0.1.2-py3-none-any.whl
Is there any way of upload the content using wildcards as i am trying to do?
Thanks
The text was updated successfully, but these errors were encountered: