actions / checkout

Action for checking out a repo
https://github.com/features/actions
MIT License
5.93k stars 1.76k forks source link

Checking out HEADs of submodules #503

Open vvasuki opened 3 years ago

vvasuki commented 3 years ago

I recently had much trouble using this action as part of an attempt to checkout submoudle HEADS - See here . It would be great if the action were to be able to do it automatically! Anyway, what I tried was:

    - name: Checkout
      uses: actions/checkout@master
      with:
        submodules: true
        fetch-depth: 1
    - name: Update submodules
      if: ${{ github.event_name != 'pull_request'}}
      run: |
        git pull --recurse-submodules --depth 1
        git submodule update --remote --merge

The result was:

Run git pull --recurse-submodules --depth 1
From https://github.com/vvasuki/kAvyam
 * [new branch]      content         -> origin/content
 * [new branch]      gh-pages        -> origin/gh-pages
 * [new branch]      offline_android -> origin/offline_android
 * [new branch]      trigger_branch  -> origin/trigger_branch
Fetching submodule content
Fetching submodule themes/sanskrit-documentation-theme-hugo
Already up to date.
fatal: Needed a single revision
Unable to find current origin/content revision in submodule path 'content'
Error: Process completed with exit code 1.

The following worked:

Disabling submodules initialization in the action as below

    - name: Checkout
      uses: actions/checkout@master
      with:
        submodules: false

Manual updation:

    - name: Update submodules
      if: ${{ github.event_name != 'pull_request'}}
      run: |
        set -o xtrace
        git submodule update --init --recursive
        git submodule update --remote --merge --recursive
AraHaan commented 3 years ago

I recently had much trouble using this action as part of an attempt to checkout submoudle HEADS - See here . It would be great if the action were to be able to do it automatically! Anyway, what I tried was:

    - name: Checkout
      uses: actions/checkout@master
      with:
        submodules: true
        fetch-depth: 1
    - name: Update submodules
      if: ${{ github.event_name != 'pull_request'}}
      run: |
        git pull --recurse-submodules --depth 1
        git submodule update --remote --merge

The result was:

Run git pull --recurse-submodules --depth 1
From https://github.com/vvasuki/kAvyam
 * [new branch]      content         -> origin/content
 * [new branch]      gh-pages        -> origin/gh-pages
 * [new branch]      offline_android -> origin/offline_android
 * [new branch]      trigger_branch  -> origin/trigger_branch
Fetching submodule content
Fetching submodule themes/sanskrit-documentation-theme-hugo
Already up to date.
fatal: Needed a single revision
Unable to find current origin/content revision in submodule path 'content'
Error: Process completed with exit code 1.

The following worked:

Disabling submodules initialization in the action as below

    - name: Checkout
      uses: actions/checkout@master
      with:
        submodules: false

Manual updation:

    - name: Update submodules
      if: ${{ github.event_name != 'pull_request'}}
      run: |
        set -o xtrace
        git submodule update --init --recursive
        git submodule update --remote --merge --recursive

The issue is because you specified depth of 1 to the action remove that line and the issue would go away.

Also depth of 1 on that command would be problematic as well, that is why you run into that issue too.

vvasuki commented 3 years ago

The issue is because you specified depth of 1 to the action remove that line and the issue would go away.

Also depth of 1 on that command would be problematic as well, that is why you run into that issue too.

https://github.com/vvasuki/kAvyam/runs/2618045918?check_suite_focus=true run of the workflow file https://github.com/vvasuki/kAvyam/actions/runs/856080271/workflow shows that removing depth 1 argument does not help.