首页 > 解决方案 > 访问 Github 工作流的工件

问题描述

我是 Github 工作流程的新手,在下载我的工件表单完成的工作流程时有些吃力。

我的工作流程运行良好:构建项目并上传工件

- name: 4. Store artifact in GitHub
  uses: actions/upload-artifact@v2
  with:
    name: my-artifact
    path: target/my-project.jar
    retention-days: 1
    if-no-files-found: error

上传工件后,我在我的服务器上触发端点,假设下载和部署我的工件。

- name: 5. Run deploy on server
  uses: fjogeleit/http-request-action@master
  with:
    url: 'my-endpoint'
    method: 'POST'
    contentType: application/x-www-form-urlencoded
    data: '{"run-id": "${{github.run_id}}", "repo": "${{github.repository}}", "secret": "${{ secrets.GITHUB_TOKEN }}"}'
    preventFailureOnNoResponse: 'true'

在工作流完成并且我的服务器收到开始部署过程的请求后,该工件可用。

我现在面临的挑战是授权。最初我使用我的“个人访问令牌”来下载文件(并且它有效),但这看起来是错误的(使用我的私人令牌)。

我试图找出是否有一个临时令牌(或类似的东西)可以让我从外部服务器下载我的工件。我尝试了 secrets.GITHUB_TOKEN 但这对我不起作用(或者我用错了)。

以下是我检查工件的方法: https ://api.github.com/repos/${owner}/${repo}/actions/runs/${id}/artifacts

您能否指出我如何在不提供私人令牌的情况下从工作流程中获取我的工件?

谢谢。

标签: githubgithub-actionsgithub-api

解决方案


推荐阅读