1 Commits

Author SHA1 Message Date
mo7sen 8b22fe549b Support multiple unarchived file uploads 2026-05-05 18:23:13 +03:00
4 changed files with 39 additions and 18 deletions
+4 -1
View File
@@ -1,3 +1,6 @@
Vendored from actions/upload-artifact v7.0.1. Vendored from actions/upload-artifact v7.0.1.
Patch: dist/upload/index.js isGhes() returns false so Gitea Actions is not rejected as GHES. Patches:
- `dist/upload/index.js` `isGhes()` returns false so Gitea Actions is not rejected as GHES.
- `archive: false` supports multiple matched files by uploading each file as a separate unarchived artifact named after the file basename.
+17 -7
View File
@@ -2,21 +2,31 @@
A Gitea-compatible vendored copy of `actions/upload-artifact@v7.0.1`. A Gitea-compatible vendored copy of `actions/upload-artifact@v7.0.1`.
The bundled `dist/upload/index.js` is patched so `isGhes()` returns `false`. The bundled `dist/upload/index.js` includes two Gitea patches:
Gitea sets `GITHUB_SERVER_URL` to the Gitea instance URL, which upstream
`actions/upload-artifact@v7` mis-detects as GitHub Enterprise Server and rejects 1. `isGhes()` returns `false`. Gitea sets `GITHUB_SERVER_URL` to the Gitea
before it can use Gitea's artifact runtime service. instance URL, which upstream `actions/upload-artifact@v7` mis-detects as
GitHub Enterprise Server and rejects before it can use Gitea's artifact
runtime service.
2. `archive: false` accepts multiple matched files. Upstream v7 only permits one
unarchived file; this fork uploads every matched file as a separate
unarchived artifact named after that file's basename.
## Usage ## Usage
```yaml ```yaml
- uses: mo7sen/upload-artifact-gitea@v7 - uses: https://git.neosisyphus.com/mo7sen/upload-artifact-gitea@v7
with: with:
name: meson-log.txt path: |
path: build/meson-logs/meson-log.txt build/meson-logs/meson-log.txt
build/meson-logs/testlog.txt
archive: false archive: false
``` ```
With `archive: false`, each matched file is uploaded unzipped as its own
artifact. The artifact name is the file basename, so `name` is ignored in this
mode.
## Upstream ## Upstream
Based on <https://github.com/actions/upload-artifact/releases/tag/v7.0.1>. Based on <https://github.com/actions/upload-artifact/releases/tag/v7.0.1>.
+2 -2
View File
@@ -48,8 +48,8 @@ inputs:
archive: archive:
description: > description: >
If true, the artifact will be archived (zipped) before uploading. If true, the artifact will be archived (zipped) before uploading.
If false, the artifact will be uploaded as-is without archiving. If false, files will be uploaded as-is without archiving.
When `archive` is `false`, only a single file can be uploaded. The name of the file will be used as the artifact name (ignoring the `name` parameter). When `archive` is `false`, every matched file is uploaded as a separate unarchived artifact. The basename of each file is used as the artifact name (ignoring the `name` parameter).
default: 'true' default: 'true'
outputs: outputs:
+16 -8
View File
@@ -130597,14 +130597,6 @@ async function run() {
const s = searchResult.filesToUpload.length === 1 ? '' : 's'; const s = searchResult.filesToUpload.length === 1 ? '' : 's';
info(`With the provided path, there will be ${searchResult.filesToUpload.length} file${s} uploaded`); info(`With the provided path, there will be ${searchResult.filesToUpload.length} file${s} uploaded`);
core_debug(`Root artifact directory is ${searchResult.rootDirectory}`); core_debug(`Root artifact directory is ${searchResult.rootDirectory}`);
// Validate that only a single file is uploaded when archive is false
if (!inputs.archive && searchResult.filesToUpload.length > 1) {
setFailed(`When 'archive' is set to false, only a single file can be uploaded. Found ${searchResult.filesToUpload.length} files to upload.`);
return;
}
if (inputs.overwrite) {
await deleteArtifactIfExists(inputs.artifactName);
}
const options = {}; const options = {};
if (inputs.retentionDays) { if (inputs.retentionDays) {
options.retentionDays = inputs.retentionDays; options.retentionDays = inputs.retentionDays;
@@ -130614,6 +130606,22 @@ async function run() {
} }
if (!inputs.archive) { if (!inputs.archive) {
options.skipArchive = true; options.skipArchive = true;
// Gitea patch: upstream upload-artifact@v7 only supports skipArchive
// for one file per artifact. Accept multi-path/multi-file input by
// creating one unarchived artifact for each matched file. In
// skipArchive mode the library names the artifact after the file's
// basename, matching upstream single-file behavior.
for (const fileToUpload of searchResult.filesToUpload) {
const artifactName = external_path_.basename(fileToUpload);
if (inputs.overwrite) {
await deleteArtifactIfExists(artifactName);
}
await upload_artifact_uploadArtifact(artifactName, [fileToUpload], searchResult.rootDirectory, options);
}
return;
}
if (inputs.overwrite) {
await deleteArtifactIfExists(inputs.artifactName);
} }
await upload_artifact_uploadArtifact(inputs.artifactName, searchResult.filesToUpload, searchResult.rootDirectory, options); await upload_artifact_uploadArtifact(inputs.artifactName, searchResult.filesToUpload, searchResult.rootDirectory, options);
} }