nyfair / mpv-win64

MPV Player Win64 Auto Build Bot
19 stars 3 forks source link

关于cache的问题 #10

Closed eko5624 closed 2 years ago

eko5624 commented 2 years ago

前2天我测试mcf_20220410,生成过一次cache,不过key名字没改,还是原来的。而且生成的cache是错误的(因为不懂编程自己瞎改的)。现在我想再强制生成一次cache,还用原来的key覆盖掉上次的cache,不过行不通。不会生成新cache。因为key一样。

难道必须要修改key名字才可以么。如果改了key名就要改autoupdate.py了吧。要不然下次mcf有更新就不能同步更新了。

nyfair commented 2 years ago

这个有人反应过,github的人看上去不想加手动覆盖或删除的功能。有个变通的办法是像密钥token一样在变量名称里加个github环境变量,然后每次想更新缓存了就手动改下它的值

eko5624 @.***> 于 2022年4月12日周二 06:56写道:

前2天我测试mcf_20220410,生成过一次cache,不过key名字没改,还是原来的。而且生成的cache是错误的(因为不懂编程自己瞎改的)。现在我想再强制生成一次cache,还用原来的key覆盖掉上次的cache,不过行不通。不会生成新cache。因为key一样。

难道必须要修改key名字才可以么。如果改了key名就要改autoupdate.py了吧。要不然下次mcf有更新就不能同步更新了。

— Reply to this email directly, view it on GitHub https://github.com/nyfair/mpv-win64/issues/10, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAKH7M4I7THFBLHZGVAFVYTVESU23ANCNFSM5TEU34JQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

eko5624 commented 2 years ago

这个具体该怎么写呢,求打个样哈~

nyfair commented 2 years ago

key: ${{ secrets.TESTXXXX }}

eko5624 @.***> 于 2022年4月12日周二 11:04写道:

这个具体该怎么写呢,求打个样哈~

— Reply to this email directly, view it on GitHub https://github.com/nyfair/mpv-win64/issues/10#issuecomment-1095893969, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAKH7MYGD5KQOWSJR5N6SP3VETR2XANCNFSM5TEU34JQ . You are receiving this because you commented.Message ID: @.***>

eko5624 commented 2 years ago

加secrets变量的实现方式其实也不友好,因为要update secrets才能生成不同的key值。目前看来没有更好的方法了,先这样吧。

eko5624 commented 2 years ago

用下面这个更好一些: key: ${{ github.sha }} 想强制更新cache就提交一次commit就行咯~

eko5624 commented 2 years ago

参考了别人的代码,算是比较完美的强制重建cache的方法了:

name: toolchain

on:
  workflow_dispatch:

  schedule:
    - cron: '10 0 * * MON'  
jobs:
  autogreen:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Auto green
        run: |
          git config --local user.email 'datong5624@gmail.com'
          git config --local user.name 'eko5624'
          git remote set-url origin https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
          git pull --rebase
          git commit --allow-empty -m "nothing commit"
          git push  
  build:
    needs: [autogreen]
    runs-on: windows-2022
    steps: 
    - uses: msys2/setup-msys2@v2
      with:
        location: D:\
        install: base-devel autotools        
    - name: Setup Toolchain
      run: |
        curl -OL https://gcc-mcf.lhmouse.com/mingw-w64-gcc-mcf_20220410_11.2.1_x64-ucrt_56bec19863100ebc6200bae496e48317f8ae09bb.7z
        &'C:\Program Files\7-Zip\7z.exe' x *.7z -o'D:'
    - name: Prepare
      run: git config --global core.autocrlf input
    - uses: actions/checkout@v3     
    - name: Make Toolchain
      shell: msys2 {0}
      run: |
        cd mcfgthread; PATH=/usr/bin:/opt/bin:/d/ucrt64/bin PKG_CONFIG_PATH=/opt/lib/pkgconfig makepkg    

    - name: Cache
      id: cache
      uses: actions/cache@v3
      with:
        path: D:\ucrt64
        key: ${{ github.sha }}   

    - name: Delete
      uses: mknejp/delete-release-assets@v1
      with:
        token: ${{ secrets.GITHUB_TOKEN }}
        tag: latest
        assets: mcfgthread*
        fail-if-no-assets: false
        fail-if-no-release: false        
    - name: Upload
      uses: svenstaro/upload-release-action@v2
      with:
        repo_token: ${{ secrets.GITHUB_TOKEN }}
        file: mcfgthread/*pkg*.xz
        tag: latest
        overwrite: true
        file_glob: true
eko5624 commented 2 years ago

上面的代码需要再做修改。应该分别新建2个yml文件:一个autogreen.yml, 一个toolchain.yml. 运行toolchain时应该先运行autogreen.yml。

eko5624 commented 2 years ago

toolchain前面加上这些就可以了。autogreen.yml成功运行后就会自动运行toolchain.yml。

name: toolchain

on:
  workflow_run:
    workflows: [rebuild-toolchain]
    types: [completed]

jobs:
  on-success:
    runs-on: windows-2022
    if: ${{ github.event.workflow_run.conclusion == 'success' }}