Skip to content

Using checkout twice, keeping the previous folder #33

@thewavelength

Description

@thewavelength

What do I wanto to achieve?
I want to deploy the master-branch and the beta-branch to gh-pages at the same time. master should go to gh-pages/ (root folder) and beta-branch to gh-pages/beta-folder.

My idea
Currently I'm using actions/checkout twice (in a single job) with those two different branches. First I do checkout, then npm install && npm run build. Works quite well, until the second actions/checkout is executed. This action seems to remove the previous folder including all build results, so I'm unable to move both builds to a deploy-folder to finally publish it to gh-pages. See parts of my script for details:

    steps:
    - name: Use Node.js ${{ matrix.node-version }}
      uses: actions/setup-node@v1
      with:
        node-version: ${{ matrix.node-version }}
    - name: Checking out master
      uses: actions/checkout@v1
      with:
        ref: master
        path: master
    - name: Build master
      run: |
        npm install
        npm run build --if-present
      env:
        CI: true
# at this point, everything from master has been built and is on the filesystem of the runner
    - name: Checking out beta
      uses: actions/checkout@v1
      with:
        ref: beta
        path: beta
# at this point, everything from master seems to be lost in the filesystem
    - name: Build beta
      run: |
        npm install
        npm run build --if-present
      env:
        CI: true
    - name: GitHub Pages Deploy
      uses: maxheld83/ghpages@v0.2.1
      env:
        BUILD_DIR: deploy/
        GH_PAT: ${{ secrets.GH_PAT }}

Questions

  1. Why is this behaviour? Am I understanding actions/checkout wrong?
  2. Is there a better strategy to use to publish multiple things to gh-pages?

Notes
This idea works when not using actions/checkout but raw git clone. I guess that actions/checkout runs in some sort of docker container, which will be burned after operation.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions