Giter VIP home page Giter VIP logo

Comments (7)

andry81 avatar andry81 commented on August 28, 2024

@bamfbamf Where did you create the PAT? Where did you add the PAT? Where the workflow yml file added? Is that another repo or organization?

I have tested the workflow with the same repository which has been checkout. It had not errors.

on:
  workflow_dispatch:

jobs:
  test:
    runs-on: ubuntu-latest

    steps:
      - uses: andry81-devops/gh-action--git-checkout@master
        with:
          token: '${{secrets.MY_PAT}}'
          repository: '${{github.event.repository.owner.login}}/Foo'
          ref: 'main'
          path: 'test123'

from gh-action--git-checkout.

bamfbamf avatar bamfbamf commented on August 28, 2024

Thanks for fast reply.

All repositories are organization repos created by me.
All organizations are owned by me too.

Those are all .github-private repos under which I have some common actions in .github/workflows which I can perform for organization. One of them is creation of repository with custom name and some predefined scripts/actions that are generated.

PAT is generated under my personal account Settings/Developer Settings/Personal access tokens/Classic. So those are not organization specific PATs.
PAT is added to each of those .github-private directly, so no organization wide PAT. That's what I can do on my plan under organization.

As I said, it was working perfectly fine at least till May 2023. Since January 2023 I was working on generator of scripts/actions that I could use to keep all my repos in sync. Around that time I setup all .github-private and they all have create-repository.yml that was used to setup all repos under those organizations.

from gh-action--git-checkout.

andry81 avatar andry81 commented on August 28, 2024

@bamfbamf I still could not reproduce this.

There is several variants to do:

  1. You can take a previous version if you think it would work for you: andry81-devops/gh-action--git-checkout@2af46a2d14b2afe99d90c5d32259d7a510086aaa or andry81-devops/[email protected]

  2. The code 2 means the ref is not found:

https://git-scm.com/docs/git-ls-remote.html#Documentation/git-ls-remote.txt---exit-code

--exit-code

Exit with status "2" when no matching refs are found in the remote repository. Usually the command exits with status "0" to indicate it successfully talked with the remote repository, whether it found any matching refs.

This indicates either the ref is absent or repository is empty. It looks like the command exits immediately just like you have set -e permanently enabled for some reason.

Could you introduce a minimal example in GitHub Actions?

from gh-action--git-checkout.

bamfbamf avatar bamfbamf commented on August 28, 2024

Steps to reproduce:

  1. Create organization assigned to your personal account (use Skip this step)
  2. Create empty .github-private private repository with all set to default settings.
  3. In settings of .github-private go to Secrets and variables => Actions and setup MY_PAT secret with your generated PAT.
  4. Create .github/workflows directory in .github-private and add two files there:
  • create-repository.yml
name: Create Repository

# Controls when the action will run, and on which branches
on:
  workflow_dispatch:
    inputs:
      repository_name: 
        description: 'Name of the repository'
        required: true
        default: ''

      should_debug:
        type: boolean
        description: Debug environment
        default: false

# Global environment variables for all jobs
env:      
  NEW_REPO_WORK_DIR: 'NEW_REPO'
  DEFAULT_BRANCH: '${{github.event.repository.default_branch}}'

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:

  # Use reusable workflow
  DebugEnvironment:
    if: ${{github.event.inputs.should_debug == 'true'}}
    uses: ./.github/workflows/debug-environment.yml

  # Job No. 1 name:
  create:
    
    # The type of runner that the job will run on
    #runs-on: self-hosted
    runs-on: ubuntu-latest

    # Steps represent a sequence of tasks that will be executed as part of the job     
    steps:

      - name: Create Repository
        uses: repo-ctrl/create-repo-action@main 
        id: create-repo
        with:
          org-admin-token: '${{secrets.MY_PAT}}'
          repo-name: '${{github.event.inputs.repository_name}}'
      
      - name: Initialize Default Branch
        uses: peterjgrainger/[email protected]
        env:
          GITHUB_TOKEN: '${{secrets.MY_PAT}}'
        with:
          branch: '${{env.DEFAULT_BRANCH}}'

      - uses: andry81-devops/gh-action--git-checkout@master
        with:
          token: '${{secrets.MY_PAT}}'
          repository: '${{github.event.repository.owner.login}}/${{github.event.inputs.repository_name}}'
          ref: '${{env.DEFAULT_BRANCH}}'
          path: '${{env.NEW_REPO_WORK_DIR}}'
          mkdir-p: >-
  • debug-environment.yml
name: Debug Environment

# Controls when the action will run, and on which branches
on:
 workflow_dispatch:
 workflow_call:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:

 # Job No. 1 name:
 debug:
   
   # The type of runner that the job will run on
   #runs-on: self-hosted
   runs-on: ubuntu-latest

   # Steps represent a sequence of tasks that will be executed as part of the job       
   steps:

# ------------------------------- DEBUG INFO

     # Print event that launched the action, for debug
     - name: PWSH Event Info
       shell: pwsh
       run: |
         $workflow = Get-ChildItem env:"GITHUB_WORKFLOW"
         $event = Get-ChildItem env:"GITHUB_EVENT_NAME"
         Write-Host ("{0} : {1}`n{2} : {3}" -f $workflow.Name, $workflow.Value, $event.Name, $event.Value)

     # Print event file to output, for debug
     - name: PWSH Event File
       shell: pwsh
       run: |
         $eventFile = Get-ChildItem env:"GITHUB_EVENT_PATH"
         if (Test-Path -Path $eventFile.Value -PathType Leaf) { Get-Content -Path $eventFile.Value | Write-Host }

     # Print environment variables to output, for debug
     - name: PWSH Environment Info 
       shell: pwsh
       run: |
         Get-ChildItem env: 
  1. Run create-repository.yml with some random repository name.

This is minimal example that creates empty repository but again fails at the andry81-devops/gh-action--git-checkout@master.

from gh-action--git-checkout.

bamfbamf avatar bamfbamf commented on August 28, 2024

Version andry81-devops/[email protected] worked

from gh-action--git-checkout.

andry81 avatar andry81 commented on August 28, 2024

The minimal example I've could to reproduce:

  1. Create organization assigned to your personal account
  2. Create empty .github-private private repository with all set to default settings.
  3. Create empty boo private repository with all set to default settings.
  4. In settings of boo go to Secrets and variables => Actions and setup MY_PAT secret with your generated PAT.
  5. Create in .github-private repo:
  • .github/workflows/test.yml
on:
  workflow_dispatch:

jobs:
  test:
    runs-on: ubuntu-latest

    steps:
      - uses: andry81-devops/gh-action--git-checkout@master
        with:
          token: '${{secrets.MY_PAT}}'
          repository: '${{github.event.repository.owner.login}}/Boo'
          ref: 'main'
          path: 'NEW_REPO'
          mkdir-p: >-

Seems the .github-private is a special private repository which has a kind of different default configuration versus usual private repository.

If try to create it, then the GitHub issue a tip message:

andry81-tests/.github-private is a ✨special ✨ repository that you can use to add a README.md to your organization member profile, visible only to organization members. It’s private and initialize it with a README in the profile directory to get started.

I've could not find anything useful about it in the google. Seems this is kind of private documentation or not yet indexed. Even several AI search engines that I know could not clearly answer to that and reference some actual information: what is ".github-private" repository?.

from gh-action--git-checkout.

bamfbamf avatar bamfbamf commented on August 28, 2024

I can confirm that fix seems to solve the problem.

from gh-action--git-checkout.

Related Issues (2)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.