]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
action: Ensure git history is available
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 8 Apr 2025 12:39:43 +0000 (14:39 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 8 Apr 2025 12:49:45 +0000 (14:49 +0200)
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.

action.yaml

index 019a816979d2e736c220eda120be0856cfb18095..984186523316b3a0ee9350d1b5971b978dee9405 100644 (file)
@@ -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