[actions/upload-artifact] Wrong artifact-id and artifact-url #187

Open
opened 2024-05-02 21:46:44 +00:00 by f00 · 0 comments

The action upload-artifact provides two outputs:

  • artifact-url
  • artifact-id

The URL will construct the following way:

const artifactURL = `${github.context.serverUrl}/${repository.owner}/${repository.repo}/actions/runs/${github.context.runId}/artifacts/${uploadResponse.id}`

So, runId and uploadResponse.id is used. runID comes from the runner itself(?)

runner.go:

...
	preset := &model.GithubContext{
		Event:           taskContext["event"].GetStructValue().AsMap(),
		RunID:           taskContext["run_id"].GetStringValue(),
		RunNumber:       taskContext["run_number"].GetStringValue(),
...

This results in the following artifact-url (output), which is broken (HTTP 404):

https://<host>/<user>/<project>/actions/runs/162/artifacts/58

The correct artifact-url (taken from the Web-UI) should be the following:

https://<host>/<user>/<project>/actions/runs/47/artifacts/website-content

This is my runner workflow:

jobs:
  build:
    runs-on: docker
    outputs:
      artifacturl: ${{ steps.artifact-upload.outputs.artifact-url }}
      artifactid: ${{ steps.artifact-upload.outputs.artifact-id }}
    steps:
...
      - name: Build artifact
        id: artifact-upload
        uses: https://code.forgejo.org/forgejo/upload-artifact@v4
        with:
          name: website-content
          path: /...
  deploy:
    runs-on: self-hosted
    needs: build
    steps:
      - name: Deploy
        env:
          ARTIFACT_URL: ${{needs.build.outputs.artifacturl}}
          ARTIFACT_ID: ${{needs.build.outputs.artifactid}}
        run: |
          echo $ARTIFACT_URL
          echo $ARTIFACT_ID

It looks like github is using a different URI then forgejo. RunID should be the RunNumber and the artifact-id should be the name of the artifact rather than an ID.

The action ```upload-artifact``` provides two outputs: * artifact-url * artifact-id The URL will construct the following way: ``` const artifactURL = `${github.context.serverUrl}/${repository.owner}/${repository.repo}/actions/runs/${github.context.runId}/artifacts/${uploadResponse.id}` ``` So, ```runId``` and ```uploadResponse.id``` is used. runID comes from the runner itself(?) runner.go: ``` ... preset := &model.GithubContext{ Event: taskContext["event"].GetStructValue().AsMap(), RunID: taskContext["run_id"].GetStringValue(), RunNumber: taskContext["run_number"].GetStringValue(), ... ``` This results in the following artifact-url (output), which is broken (HTTP 404): ``` https://<host>/<user>/<project>/actions/runs/162/artifacts/58 ``` The correct artifact-url (taken from the Web-UI) should be the following: ``` https://<host>/<user>/<project>/actions/runs/47/artifacts/website-content ``` This is my runner workflow: ``` jobs: build: runs-on: docker outputs: artifacturl: ${{ steps.artifact-upload.outputs.artifact-url }} artifactid: ${{ steps.artifact-upload.outputs.artifact-id }} steps: ... - name: Build artifact id: artifact-upload uses: https://code.forgejo.org/forgejo/upload-artifact@v4 with: name: website-content path: /... deploy: runs-on: self-hosted needs: build steps: - name: Deploy env: ARTIFACT_URL: ${{needs.build.outputs.artifacturl}} ARTIFACT_ID: ${{needs.build.outputs.artifactid}} run: | echo $ARTIFACT_URL echo $ARTIFACT_ID ``` It looks like github is using a different URI then forgejo. ```RunID``` should be the ```RunNumber``` and the ```artifact-id``` should be the name of the artifact rather than an ID.
earl-warren added the
Kind/Bug
label 2024-05-03 07:21:31 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: forgejo/runner#187
No description provided.