Skip to content

is /vendor folder being deleted by the action? #168

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
cristiano-federico-jump opened this issue May 2, 2025 · 5 comments
Open

is /vendor folder being deleted by the action? #168

cristiano-federico-jump opened this issue May 2, 2025 · 5 comments
Labels
needs:feedback This requires reporter feedback to better understand the request. type:question Further information is requested.

Comments

@cristiano-federico-jump
Copy link

Hi,
I'm using the 10up/action-wordpress-plugin-deploy action to deploy a plugin to the WordPress SVN repository.

I confirmed that:

  • composer install --no-dev runs correctly before deploy
  • vendor/ is present at the repository root before the deploy step
  • There is no .distignore file in my repository
  • Running ls -la vendor and find . -type f in the workflow shows that vendor/autoload.php exists before deploy

However, the vendor/ directory does not appear in the SVN repository after deployment.

This is my workflow

name: Deploy to WordPress SVN

on:
  push:
    tags:
      - '*'

jobs:
  deploy:
    name: Deploy Plugin to WordPress SVN
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Code
        uses: actions/checkout@v2

      - name: Get Version from Tag
        run: echo "PLUGIN_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV

      - name: Debug Version
        run: echo "Deploying version $PLUGIN_VERSION"

      - name: List vendor directory
        run: ls -la vendor

      - name: Validate SemVer Tag
        run: |
          if [[ ! "$PLUGIN_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(--[a-zA-Z0-9._-]+)?$ ]]; then
            echo "❌ Invalid tag format: $PLUGIN_VERSION"
            exit 1
          fi
          echo "✅ Valid SemVer tag: $PLUGIN_VERSION"

      # - name: Update Version in Files (Temporary)
      #   run: |
      #     sed -i "s/^Stable tag: .*/Stable tag: $PLUGIN_VERSION/" readme.md
      #     sed -i "s/^Stable tag: .*/Stable tag: $PLUGIN_VERSION/" avacy.php
      #     sed -i "s/^Version: .*/Version: $PLUGIN_VERSION/" avacy.php

      - name: WordPress Plugin Deploy
        uses: 10up/[email protected]
        env:
          SLUG: avacy
          VERSION: ${{ env.PLUGIN_VERSION }}
          SVN_USERNAME: ${{ secrets.SVN_USERNAME }}
          SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }}

I also tried to copy the vendor folder into another folder named test just for testing:

- name: Run Composer Install
        run: composer install --no-dev --no-scripts --prefer-dist --optimize-autoloader

- name: Copy vendor directory
        run: cp -R vendor/ test/

And it turned out that the test folder was actually deployed in the Wordpress repository.

Is there any reason vendor/ might be silently excluded from the deploy even though it is present and not listed in any .distignore?

Thanks in advance!

@cristiano-federico-jump cristiano-federico-jump changed the title /vendor folder could be deleted by the action? is /vendor folder being deleted by the action? May 2, 2025
@dkotter
Copy link
Collaborator

dkotter commented May 2, 2025

So we don't delete any files or folders ourselves, we look at .distignore or .gitattributes file and use that for what shouldn't be synced (if you're interested, can see how that works here https://github.com/10up/action-wordpress-plugin-deploy/blob/develop/deploy.sh#L129).

You mention:

There is no .distignore file in my repository

In this case, we fallback to using the .gitattributes file. Does this exist in your repo? If not, we end up creating a basic one which will also consider your .gitignore file. See https://github.com/10up/action-wordpress-plugin-deploy?tab=readme-ov-file#excluding-files-from-deployment for more information on this but if you have files or folders that are excluded by .gitignore but these are things you want deployed, best way to achieve this is adding a .distignore file to ensure these files/folders aren't excluded.

Here's an example .distignore file from one of our plugins that does need the vendor directory deployed and this works.

@jeffpaul jeffpaul added type:question Further information is requested. needs:feedback This requires reporter feedback to better understand the request. labels May 2, 2025
@cristiano-federico-jump
Copy link
Author

So we don't delete any files or folders ourselves, we look at .distignore or .gitattributes file and use that for what shouldn't be synced (if you're interested, can see how that works here https://github.com/10up/action-wordpress-plugin-deploy/blob/develop/deploy.sh#L129).

You mention:

There is no .distignore file in my repository

In this case, we fallback to using the .gitattributes file. Does this exist in your repo? If not, we end up creating a basic one which will also consider your .gitignore file. See https://github.com/10up/action-wordpress-plugin-deploy?tab=readme-ov-file#excluding-files-from-deployment for more information on this but if you have files or folders that are excluded by .gitignore but these are things you want deployed, best way to achieve this is adding a .distignore file to ensure these files/folders aren't excluded.

Here's an example .distignore file from one of our plugins that does need the vendor directory deployed and this works.

Hi @dkotter, thanks for the reply!
If I understood correctly, the .gitattributes file is created by the action (since I don't have any .gitattributes file in my repo) based on my .gitignore (where the vendor/ folder rule actually exists), hence removing the folder from the final package.

We tried to add .distignore file copying all the rules in the .gitignore and removing the vendor folder but the folder is still missing. Am I doing something wrong?

This is my .distignore

wp/*
build/*
.env

// other project folders...

.git
.github
.distignore
.gitignore

Could you provide the .distignore example you mentioned in the previous comment? Don't see any link and I'm not sure if there was supposed to be one in your comment.

Thanks again!

@dkotter
Copy link
Collaborator

dkotter commented May 5, 2025

Ah, sorry, meant to copy/paste the link to the .distignore file but looks like I missed that. Here's what I was referencing as an example: https://github.com/10up/restricted-site-access/blob/develop/.distignore

If I understood correctly, the .gitattributes file is created by the action (since I don't have any .gitattributes file in my repo) based on my .gitignore (where the vendor/ folder rule actually exists), hence removing the folder from the final package.

So this isn't exactly correctly but close. Here's how it works:

  1. If you have BUILD_DIR set, we copy all files from that directory and don't consider .distignore or .gitattributes
  2. Otherwise if you have a .distignore, we ignore all files and directories that are in that when running our rsync command
  3. If you don't have either of those but you do have a .gitattributes file, that will be used when we run git archive. That command will also consider your .gitignore file
  4. If none of the above conditions are met, we then create a basic .gitattributes file that ignores a few files and then that will be used when we run git archive, which again, will also consider your .gitignore file

@cristiano-federico-jump
Copy link
Author

Hello, I tried using BUILD_DIR in my workflow as shown in the code:

- name: Prepare build directory
        run: |
          mkdir build
          rsync -av --exclude=build --exclude=.git --exclude=.github --exclude=node_modules ./ build/

- name: Install PHP dependencies in build
        run: |
          composer install --no-dev --prefer-dist --no-interaction --optimize-autoloader --working-dir=build
          ls -la build/vendor

- name: WordPress Plugin Deploy
        uses: 10up/[email protected]
        env:
          SLUG: avacy
          VERSION: ${{ env.PLUGIN_VERSION }}
          SVN_USERNAME: ${{ secrets.SVN_USERNAME }}
          SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }}
          BUILD_DIR: build

but still no vendor folder inside the final package.

Would it be a good idea to run composer install --no-dev... in the local environment and commit the generated files inside the repository? I'm aware it might not be the best practice but I can't figure out where the problem is.

Thanks again!

@dkotter
Copy link
Collaborator

dkotter commented May 9, 2025

Hmm.. at a quick glance that seems like it should work, though I'll note I haven't tested using a custom BUILD_DIR in a while (and don't believe any of our plugins uses that). I'm assuming there's something else going on that's excluding that but not sure.

Would it be a good idea to run composer install --no-dev... in the local environment and commit the generated files inside the repository?

You can definitely go with that approach if you don't mind those files in your repo, though since I'm not sure why that directory is being removed with the various approaches you've already tried so it may also be removed even if directly in the repo unfortunately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs:feedback This requires reporter feedback to better understand the request. type:question Further information is requested.
Projects
Status: Incoming
Development

No branches or pull requests

3 participants