<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Development on NCJ Tech Blog</title>
    <link>https://blog.chong-zeng.com/tags/development/</link>
    <description>Recent content in Development on NCJ Tech Blog</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en</language>
    <lastBuildDate>Mon, 16 Mar 2020 00:00:00 +0000</lastBuildDate>
    <atom:link href="https://blog.chong-zeng.com/tags/development/rss.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>GitHub Actions无法上传到Release的问题</title>
      <link>https://blog.chong-zeng.com/posts/2020-03-16_github_actions/</link>
      <pubDate>Mon, 16 Mar 2020 00:00:00 +0000</pubDate>
      <guid>https://blog.chong-zeng.com/posts/2020-03-16_github_actions/</guid>
      <description>最近在尝试使用 Github Actions 自动编译、发布树莓派Openwrt固件的时候，遇到了 Release 发布失败的问题。
可以看到 Create Release 这一步发生了错误 Bad credentials ，这个错误一般是调用 GitHub Release API 的时候 TOKEN 错误导致的，但是在我们这里是 GitHub 自动生成的 TOKEN ，照说应该一点问题都没有才对啊。
后来查找资料得知是因为 GitHub 为 Actions 的每一个 Workflow 都会申请一个临时的 TOKEN ，但是这个TOKEN 只有一个小时的失效，而我们的编译持续了一个半小时，此时的 TOKEN 已经失效了， 因此不再有效。
GitHub给出了一个解决的办法，就是创建不同的 Workflow，先单独编译，编译完成之后再将固件传到一个第三方的位置（比如你的云盘），然后再单独一个 Workflow 进行发布。
另外一种办法就是使用永久的 TOKEN ，但是对于公开仓库这显然不安全，所以可以考虑创建一个 private repo 在里面编译然后通过永久 TOKEN 上传到公开仓库的 Release 里。</description>
      <content:encoded><![CDATA[<p>最近在尝试使用 Github Actions 自动编译、发布<a href="https://github.com/iamNCJ/Openwrt-Pi4">树莓派Openwrt固件</a>的时候，遇到了 Release 发布失败的问题。</p>
<p><img loading="lazy" src="/old-pics/illustrations/2020-03-16_GitHub_Actions/1.png" alt="Bad credentials"  />
</p>
<p>可以看到 Create Release 这一步发生了错误 <code>Bad credentials</code> ，这个错误一般是调用 GitHub Release API 的时候 TOKEN 错误导致的，但是在我们这里是 GitHub 自动生成的 TOKEN ，照说应该一点问题都没有才对啊。</p>
<p>后来查找资料得知是因为 GitHub 为 Actions 的每一个 Workflow 都会申请一个临时的 TOKEN ，但是这个TOKEN 只有一个小时的失效，而我们的编译持续了一个半小时，此时的 TOKEN 已经失效了， 因此不再有效。</p>
<p>GitHub给出了一个<a href="https://help.github.com/en/actions/configuring-and-managing-workflows/persisting-workflow-data-using-artifacts#sharing-data-between-workflow-runs">解决的办法</a>，就是创建不同的 Workflow，先单独编译，编译完成之后再将固件传到一个第三方的位置（比如你的云盘），然后再单独一个 Workflow 进行发布。</p>
<p>另外一种办法就是使用永久的 TOKEN ，但是对于公开仓库这显然不安全，所以可以考虑创建一个 private repo 在里面编译然后通过永久 TOKEN 上传到公开仓库的 Release 里。</p>
]]></content:encoded>
    </item>
  </channel>
</rss>
