本文介绍了Github action actions/checkout @ v2 lfs:true标志不会将指针转换为实际文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的github action yml文件:

This is my github actions yml file:

name: CI

on: [pull_request]

jobs:
  build_ios:
    name: Set up
    runs-on: ${{ matrix.os }}

    strategy:
      matrix:
        os: [self-hosted]
        node-version: [10.x]

    steps:
      - name: Checkout github repo (+ download lfs dependencies)
        uses: actions/checkout@v2
        with:
          lfs: true

运行后,我希望所有git lfs文件都已下载,签出并可以使用,但是文件的内容是这样的:

After it runs I expect all the git lfs files to be downloaded, checked out and ready to use, but instead the content of the file is this:

version https://git-lfs.github.com/spec/v1
oid sha256:f23e4c2b1244bc93085dbccf17c447e54sca44650294648df128d58303e4eff
size 58951008

如果有帮助,下面附上实际的github操作日志:

Below I attach the actual github actions log in case it's helpful:

Run actions/checkout@v2
  with:
    lfs: true
    repository: SudoPlz/test-project-mobile
    token: ***
    ssh-strict: true
    persist-credentials: true
    clean: true
    fetch-depth: 1
    submodules: false
Syncing repository: SudoPlz/test-project-mobile
Getting Git version info
  Working directory is '/Users/sudoplz/Development/tmp/actions-runner/_work/test-project-mobile/test-project-mobile'
  /usr/bin/git version
  git version 2.24.1 (Apple Git-126)
  /usr/bin/git lfs version
  git-lfs/2.8.0 (GitHub; darwin amd64; go 1.12.7)
/usr/bin/git config --local --get remote.origin.url
https://github.com/SudoPlz/test-project-mobile
Removing previously created refs, to avoid conflicts
  /usr/bin/git rev-parse --symbolic-full-name --verify --quiet HEAD
  HEAD
  /usr/bin/git rev-parse --symbolic-full-name --branches
  /usr/bin/git rev-parse --symbolic-full-name --remotes=origin
Cleaning the repository
  /usr/bin/git clean -ffdx
  Removing .jest/
  Removing node_modules/
  Removing patchLog.txt
  /usr/bin/git reset --hard HEAD
  HEAD is now at 21bea25da Merge ab95479fd7dce51551520250ac521532d0079f94 into c70ec18b35029c581b0c0e06566228f69e091d3d
Disabling automatic garbage collection
  /usr/bin/git config --local gc.auto 0
Setting up auth
  /usr/bin/git config --local --name-only --get-regexp core\.sshCommand
  /usr/bin/git submodule foreach --recursive git config --local --name-only --get-regexp 'core\.sshCommand' && git config --local --unset-all 'core.sshCommand' || :
  /usr/bin/git config --local --name-only --get-regexp http\.https\:\/\/github\.com\/\.extraheader
  /usr/bin/git submodule foreach --recursive git config --local --name-only --get-regexp 'http\.https\:\/\/github\.com\/\.extraheader' && git config --local --unset-all 'http.https://github.com/.extraheader' || :
  /usr/bin/git config --local http.https://github.com/.extraheader AUTHORIZATION: basic ***
/usr/bin/git lfs install --local
Updated git hooks.
Git LFS initialized.
Fetching the repository
  /usr/bin/git -c protocol.version=2 fetch --no-tags --prune --progress --no-recurse-submodules --depth=1 origin +d4be6d58e6a72e54b0b03be61fc508dcee8d7bec:refs/remotes/pull/44/merge
  remote: Enumerating objects: 10, done.
  remote: Counting objects:  10% (1/10)
  remote: Counting objects:  20% (2/10)
  remote: Counting objects:  30% (3/10)
  remote: Counting objects:  40% (4/10)
  remote: Counting objects:  50% (5/10)
  remote: Counting objects:  60% (6/10)
  remote: Counting objects:  70% (7/10)
  remote: Counting objects:  80% (8/10)
  remote: Counting objects:  90% (9/10)
  remote: Counting objects: 100% (10/10)
  remote: Counting objects: 100% (10/10), done.
  remote: Compressing objects:  33% (1/3)
  remote: Compressing objects:  66% (2/3)
  remote: Compressing objects: 100% (3/3)
  remote: Compressing objects: 100% (3/3), done.
  remote: Total 5 (delta 2), reused 2 (delta 0), pack-reused 0
  From https://github.com/SudoPlz/test-project-mobile
   + 21bea25da...d4be6d58e d4be6d58e6a72e54b0b03be61fc508dcee8d7bec -> pull/44/merge  (forced update)
Determining the checkout info
Fetching LFS objects
  /usr/bin/git lfs fetch origin refs/remotes/pull/44/merge
  fetch: Fetching reference refs/remotes/pull/44/merge
Checking out the ref
  /usr/bin/git checkout --progress --force refs/remotes/pull/44/merge
  Warning: you are leaving 1 commit behind, not connected to
  any of your branches:

    21bea25da Merge ab95479fd7dce51551520250ac521532d0079f94 into c70ec18b35029c581b0c0e06566228f69e091d3d

  If you want to keep it by creating a new branch, this may be a good time
  to do so with:

   git branch <new-branch-name> 21bea25da

  HEAD is now at d4be6d58e Merge 8d05f53305eaef70a2d4635767b39dbfbe663b5a into c70ec18b35029c581b0c0e06566228f69e091d3d
/usr/bin/git log -1
commit d4be6d58e6a72e54b0b03be61fc508dcee8d7bec
Author: SudoPlz <*@*.*>
Date:   Fri Apr 24 18:38:50 2020 +0000

    Merge 8d05f53305eaef70a2d4635767b39dbfbe663b5a into c70ec18b35029c581b0c0e06566228f69e091d3d

推荐答案

LFS对象似乎仅基于日志来获取.您需要检出LFS文件,以便将指针文件替换为LFS对应文件.这是基于对GitHub Actions的搜索(以前从未使用过)尝试的修改后的 actions.yml :

The LFS objects seem to be only fetched based on the log. You need to checkout the LFS files inorder for the pointer files to be replaced with their LFS counterparts. Here's an attempt at a modified actions.yml based on a search on GitHub Actions (never used it before) :

name: CI

on: [pull_request]

jobs:
  build_ios:
    name: Set up
    runs-on: ${{ matrix.os }}

    strategy:
      matrix:
        os: [self-hosted]
        node-version: [10.x]

    steps:
      - name: Checkout github repo (+ download lfs dependencies)
        uses: actions/checkout@v2
        with:
          lfs: true
      - name: Checkout LFS objects
        run: git lfs checkout

如果尚未提取LFS对象,则可以将 git lfs checkout 替换为 git lfs pull .

If the LFS objects have not been fetched, then you can replace git lfs checkout with git lfs pull.

相关问题: LFS缓存

这篇关于Github action actions/checkout @ v2 lfs:true标志不会将指针转换为实际文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-18 23:46