Skip to content

bug: 🐝 The clean-exclude option is not just for cleaning #1827

Open
@koenbollen

Description

@koenbollen

Describe the bug

When setting the clean-exclude option, I was expecting it to only count for a 'clean' step/phase. But there is only one step (rsync the --delete option is just added when clean:true).

The clean-exclude is just a general exclude. If other people exclude files, these files will also not be copied over.

I think this can be fixed with a slight change to the documentation.

Reproduction Steps

Context:
I wanted to deploy to a subfolder with the commit sha as a name for each commit.

Example:

deploy:
  name: Deploy
  needs: [build] # this generates an artifact
  runs-on: ubuntu-latest
  permissions:
    contents: write
  steps:
    - uses: actions/checkout@v4
      with:
        fetch-depth: 5
    - uses: actions/download-artifact@v4
      with:
        name: my-project-${{github.ref_name}}-${{github.sha}}
        path: dist/${{github.sha}}
    - name: Get Previous Commits
      run: |
        echo "LAST_FIVE_COMMITS<<EOF" >> $GITHUB_ENV
        git rev-list --max-count=5 "${{github.sha}}" >> $GITHUB_ENV
        echo "EOF" >> $GITHUB_ENV
    - uses: JamesIves/github-pages-deploy-action@6c2d9db40f9296374acc17b90404b6e8864128c8 # v4
      with:
        folder: dist
        clean-exclude: |
          index.html
          ${{ env.LAST_FIVE_COMMITS }}
        force: false

This only leaves the index.html. Because the ${{github.sha}} i want to deploy is also part of the clean-exclude list, it's never copied over by rsync.

Logs

/usr/bin/rsync -q -av --checksum --progress /home/runner/work/action-tester/action-tester/dist/. github-pages-deploy-action-temp-deployment-folder --delete --exclude index.html --exclude pr-preview/ --exclude 4521fe79967bbb5ce2b3fb13ebc3483375bfbd3f --exclude 001e1f753cc025ef2490ae9b12282b20ed890dfe --exclude 8deac04a32622e86ddc7b560de692a084411fd33 --exclude 22aece381e3fb637c634a1270768462dba48ef7c --exclude 96f1ebeef5b14832e012bd97a628db11ac2be5f4 --exclude CNAME --exclude .nojekyll --exclude .ssh --exclude .git --exclude .github
Checking if there are files to commit…
Running post deployment cleanup jobs… 🗑️

Workflow

deploy:
  name: Deploy
  needs: [build] # this generates an artifact
  runs-on: ubuntu-latest
  permissions:
    contents: write
  steps:
    - uses: actions/checkout@v4
      with:
        fetch-depth: 5
    - uses: actions/download-artifact@v4
      with:
        name: my-project-${{github.ref_name}}-${{github.sha}}
        path: dist/${{github.sha}}
    - name: Get Previous Commits
      run: |
        echo "LAST_FIVE_COMMITS<<EOF" >> $GITHUB_ENV
        git rev-list --max-count=5 "${{github.sha}}" >> $GITHUB_ENV
        echo "EOF" >> $GITHUB_ENV
    - uses: JamesIves/github-pages-deploy-action@6c2d9db40f9296374acc17b90404b6e8864128c8 # v4
      with:
        folder: dist
        clean-exclude: |
          index.html
          ${{ env.LAST_FIVE_COMMITS }}
        force: false

Additional Comments

btw, love this action! Thank you so much. Let me know if I can help with a pull request.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions