From: Daan De Meyer Date: Tue, 8 Apr 2025 12:39:43 +0000 (+0200) Subject: action: Ensure git history is available X-Git-Tag: v26~263 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5d826177ddaa116d44ca59c95147fac67754630f;p=thirdparty%2Fmkosi.git action: Ensure git history is available Unshallowing the repository only works when the action is used as a local action within the mkosi repository. If the action is used in any other github repository, the git history is not available so we cannot unshallow the repository. Instead, detect if the git history is available and clone the repository ourselves if the git history is not available. --- diff --git a/action.yaml b/action.yaml index 019a81697..984186523 100644 --- a/action.yaml +++ b/action.yaml @@ -73,9 +73,18 @@ runs: sudo aa-teardown || true sudo apt-get remove apparmor - - name: Unshallow + - name: Ensure git history is available shell: bash - run: git -C ${{ github.action_path }} fetch --unshallow + run: | + if [[ ! -d "${{ github.action_path }}/.git" ]]; then + rm -rf "${{ github.action_path }}" + git clone "$GITHUB_ACTION_REPOSITORY" "${{ github.action_path }}" + git -C "${{ github.action_path }}" checkout "$GITHUB_ACTION_REF" + fi + env: + # https://github.com/actions/runner/issues/2473 + GITHUB_ACTION_REPOSITORY: ${{ github.action_repository }} + GITHUB_ACTION_REF: ${{ github.action_ref }} - name: Install shell: bash