Search code examples
githubversion-controlworkflowgithub-actions

How to access files stored in /github/workspace?


I am trying to create a workflow for my repo using an action which auto generates a changelog. Ideally the generated changelog should be present in the root of the master branch. But the build log of the workflow states that the CHANGELOG.md file has been stored in /github/workspace. How to solve this problem or how to access the CHANGELOG.md file?

name: Generate Changelog
on: 
  push:
    branches:
      - master

jobs:
  build:
    name: Update Changelog
    runs-on: ubuntu-latest
    steps:
      - name: Checkout master
        uses: actions/checkout@v2

      - name: Set up changelog
        uses: heinrichreimer/github-changelog-generator-action@v2.1.1
        with:
          token: ${{ secrets.GITHUB_TOKEN }}

Solution

  • It outputs the file to your current working directory on your runner. It creates a link between the docker dir the github-changelog-generator-action is running on.

    E.g. /usr/bin/docker run <... omitted> -v "/home/runner/work/TestGithubActions/TestGithubActions":"/github/workspace" when the repository name containing the workflow is TestGithubActions.

    Adding ls to your workflow

    name: Generate Changelog
    on: 
      push:
        branches:
          - master
    
    jobs:
      build:
        name: Update Changelog
        runs-on: ubuntu-latest
        steps:
          - name: Checkout master
            uses: actions/checkout@v2
    
          - name: Set up changelog
            uses: heinrichreimer/github-changelog-generator-action@v2.1.1
            with:
              token: ${{ secrets.GITHUB_TOKEN }}
          - run: |
              ls
    

    outputs this:

    Run ls
    CHANGELOG.md