bxb100 / bxb100.github.io

This is my blog
https://blog.tomcat.run
MIT License
0 stars 0 forks source link

github action 相关信息 #7

Open bxb100 opened 2 years ago

bxb100 commented 2 years ago
bxb100 commented 2 years ago
bxb100 commented 2 years ago

[^2]: https://docs.github.com/en/rest/reference/actions#create-a-workflow-dispatch-event Create a workflow dispatch event

bxb100 commented 1 year ago

如何上传可执行文件到 release 中 (draft)

  1. 首先需要先创建一个 git ref tag 对应的 draft release, 注意此时的 tag 如果没有的话 GitHub 也不会主动给你绑定 image

see https://gist.github.com/bxb100/d2fedcb3cdc897062ee03920d6ae83be

  1. upload the artifact
  2. download artifacts, and compress them
  3. using gh upload to the release
     - name: Upload
        run: |
          until gh release upload --clobber --repo ${{ github.repository }} ${{ github.event.inputs.tag }} *.zip *.tar.gz; do
            echo "Attempt $((++attempts)) to upload release artifacts failed. Will retry in 20s"
            sleep 20
          done
        timeout-minutes: 10
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Examples

bxb100 commented 1 year ago

Github Action Cache Path

https://github.com/actions/toolkit/blob/e98bae803b6520b2a331f66011d812c3af8bf6ae/packages/cache

At the beginning, I tried to understand this path as a specified file glob expression, like this: ~/.m2/repository/**

but correct the way is upload directory like this: ~/.m2/repository/*/*/*

So don't miss the point of what your need

bxb100 commented 1 year ago

Auto push to Marketplace

一般来说, GitHub action 如果要上传到 marketplace 的话需要生成 dist 目录, 但是可以通过 https://github.com/JasonEtco/build-and-tag-action 项目自动生成 dist 然后自动上传 (去除了非 dist, action.xml, 仓库大小减少了~~)

注意默认 github.token 权限问题: https://github.com/JasonEtco/build-and-tag-action/issues/40 注意一定要有 write 权限...

bxb100 commented 1 year ago

Reusable workflow

If you using a useable workflow, input with env will cause an error (test secrets, needs.xx.outputs.xxx working now)^1

The workflow is not valid. xxxx: Unrecognized named-value: 'env'. 

My work on https://github.com/BurtonQin/lockbud/pull/49 show that problems

solve the problem using a config like this:

    with:
      rust_version: ${{ needs.test.outputs.rust_version }}
bxb100 commented 1 year ago

Docker

In the Action, we have three ways to use the docker

  1. using container^1, need to notice that runner is running a docker image
  2. using service^2, it like expose a port to workflow runtime, so we don't change the runner env
  3. using docker action^3