Skip to content

About the example workflow to avoid detached head in github actions #590

@mamaredo

Description

@mamaredo

Thanks for the great tool : )

Describe the bug

Why

# .github/workflows/reg.yml

- uses: actions/checkout@v2
  with:
    fetch-depth: 0
...

- name: workaround for detached HEAD
  run: |
    git checkout ${GITHUB_REF#refs/heads/} || git checkout -b ${GITHUB_REF#refs/heads/} && git pull

If you specify 0 for fetch-depth in actions/checkout@v2, you can get all history.
Therefore, a git pull of the detached HEAD workaround is not necessary.

Reproduced step

Fix reg-suit/README.md

# .github/workflows/reg.yml

on: [push]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 0
      - name: Use Node.js v10
        uses: actions/setup-node@v1
        with:
          node-version: "10.x"
      - name: npm install, build, and test
        run: |
          npm i
      - name: workaround for detached HEAD
        run: |
          git checkout ${GITHUB_REF#refs/heads/}
      - name: run reg-suit
        run: |
          npx reg-suit run

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions