rancher/ui 使用GitHub Actions 自动生成release

619 阅读1分钟

可以用于自定义rancher的镜像使用  安装依赖包, 编译, 创建release,上传压缩包到release中

编译使用这个 会比较快一些

./scripts/build-static -s

其实这个命令编译了两次,有点坑,一次是为了压缩包而编译,另外一次是为了环境部署编译

name: CI

on:
  push:
    tags:
    - '*'

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  # This workflow contains a single job called "build"
  build:
    # The type of runner that the job will run on
    runs-on: ubuntu-latest

    # Steps represent a sequence of tasks that will be executed as part of the job
    steps:
    # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
    - uses: actions/checkout@v2

    - name: Setup Node
      uses: actions/setup-node@v1
      with:
          node-version: '10.x'

    - name: Cache multiple paths
      uses: actions/cache@v2
      with:
        path: |
          ~/cache
          !~/cache/exclude
          **/node_modules
        key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}

    - name: Install Dependencies
      run: ./scripts/update-dependencies

    - name: Build Static
      run: ./scripts/build-static -s

    - name: Create Release
      id: create_release
      uses: actions/create-release@v1
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      with:
        tag_name: ${{ github.ref }}
        release_name: Release ${{ github.ref }}
        draft: false
        prerelease: false
    - name: Upload Release Asset
      id: upload-release-asset
      uses: actions/upload-release-asset@v1
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      with:
        upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
        asset_path: dist/static/master-dev.tar.gz
        asset_name: ${{ github.ref }}.tar.gz
        asset_content_type: application/gzip

缓存可能用的有点问题, 好像并没有缓存起来.抽时间再查查API 优化一下

 第一个是上传的附件,二三是源码,创建release就会有