79 lines
2.7 KiB
YAML
79 lines
2.7 KiB
YAML
name: 'Checkout with LFS'
|
|
description: 'Checkout files with LFS enabled on a private Gitea repository. Normal LFS checkout fails because of header authentification'
|
|
|
|
inputs:
|
|
checkout-version:
|
|
description: 'The version of the checkout action (e.g. "4")'
|
|
required: false
|
|
default: '4'
|
|
|
|
runs:
|
|
using: 'composite'
|
|
steps:
|
|
- name: Checkout
|
|
if: ${{ inputs.checkout-version == '3' }}
|
|
uses: actions/checkout@v3
|
|
with:
|
|
lfs: false
|
|
|
|
- name: Create LFS file list
|
|
if: ${{ inputs.checkout-version == '3' }}
|
|
run: /usr/bin/git lfs ls-files -l | cut -d' ' -f1 | sort > .lfs-assets-id
|
|
|
|
- name: Restore LFS cache
|
|
if: ${{ inputs.checkout-version == '3' }}
|
|
uses: actions/cache@v3
|
|
id: lfs-cache
|
|
with:
|
|
path: .git/lfs
|
|
key: ${{ runner.os }}-lfs-${{ hashFiles('.lfs-assets-id') }}
|
|
|
|
- name: Checkout LFS
|
|
if: ${{ inputs.checkout-version == '3' }}
|
|
run: |
|
|
UrlBase=$GITHUB_SERVER_URL; \
|
|
UrlLfsBase=$UrlBase/${{ gitea.repository }}.git/info/lfs/objects; \
|
|
Auth=`/usr/bin/git config --get --local http.$UrlBase/.extraheader`; \
|
|
/usr/bin/git config --local http.${UrlLfsBase}/batch.extraheader "$Auth"; \
|
|
/usr/bin/git config --local http.${UrlLfsBase}/.extraheader ''
|
|
|
|
git config --local lfs.transfer.maxretries 1
|
|
|
|
/usr/bin/git lfs fetch origin refs/remotes/origin/${{ gitea.ref_name }}
|
|
/usr/bin/git lfs checkout
|
|
/usr/bin/git add .
|
|
/usr/bin/git reset --hard
|
|
|
|
- name: Checkout
|
|
if: ${{ inputs.checkout-version == '4' }}
|
|
uses: actions/checkout@v4
|
|
with:
|
|
lfs: false
|
|
|
|
- name: Create LFS file list
|
|
if: ${{ inputs.checkout-version == '4' }}
|
|
run: /usr/bin/git lfs ls-files -l | cut -d' ' -f1 | sort > .lfs-assets-id
|
|
|
|
- name: Restore LFS cache
|
|
if: ${{ inputs.checkout-version == '4' }}
|
|
uses: actions/cache@v3
|
|
id: lfs-cache
|
|
with:
|
|
path: .git/lfs
|
|
key: ${{ runner.os }}-lfs-${{ hashFiles('.lfs-assets-id') }}
|
|
|
|
- name: Checkout LFS
|
|
if: ${{ inputs.checkout-version == '4' }}
|
|
run: |
|
|
UrlBase=$GITHUB_SERVER_URL; \
|
|
UrlLfsBase=$UrlBase/${{ gitea.repository }}.git/info/lfs/objects; \
|
|
Auth=`/usr/bin/git config --get --local http.$UrlBase/.extraheader`; \
|
|
/usr/bin/git config --local http.${UrlLfsBase}/batch.extraheader "$Auth"; \
|
|
/usr/bin/git config --local http.${UrlLfsBase}/.extraheader ''
|
|
|
|
git config --local lfs.transfer.maxretries 1
|
|
|
|
/usr/bin/git lfs fetch origin refs/remotes/origin/${{ gitea.ref_name }}
|
|
/usr/bin/git lfs checkout
|
|
/usr/bin/git add .
|
|
/usr/bin/git reset --hard |