Skip to content
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

Deploying plugin with files that are not in git #17

Closed
joppuyo opened this issue Nov 24, 2019 · 8 comments
Closed

Deploying plugin with files that are not in git #17

joppuyo opened this issue Nov 24, 2019 · 8 comments
Labels
type:bug Something isn't working.

Comments

@joppuyo
Copy link

joppuyo commented Nov 24, 2019

Hey, I'm trying to deploy a plugin with a build process with composer install, npm install and webpack. When I tried deploying the plugin to w.org, it first failed because I didn't have a .git directory (I removed it during the build process).

I think this action is somehow tied to the git tag.

After I added the .git folder back, the deployment was successful but it deleted all my build files from the SVN repo, such as composer dependencies, javascript and css files. Needless to say this rendered the plugin non-functional.

I think the action is somehow tied to how git tracks the files, because my build files were not under git and they were removed.

The documentation here talks a lot about excluding files but not including them. Is it possible to use this action to deploy files that are not in the git repository?

Thanks!

@joppuyo joppuyo added the type:bug Something isn't working. label Nov 24, 2019
@helen
Copy link
Collaborator

helen commented Nov 24, 2019

@joppuyo please share your build process and whether you’re using .gitattributes or .distignore, the former also respects whatever you have in .gitignore (uses git archive underneath) and is not well-suited to built output so that may be that component of the issue, but without seeing your build process and why you’re doing things like removing the .git directory I can’t really troubleshoot further.

@joppuyo
Copy link
Author

joppuyo commented Nov 24, 2019

Hey, here's the workflow I tried to use: https://github.com/joppuyo/acf-image-aspect-ratio-crop/blob/v3.1.4/.github/workflows/main.yml

Here's the build log

It generates right output into the artifact (top right corner), github releases and into my packagist release repo

However, the w.org deployment is missing all the distribution files (note the removal of trunk/assets/dist and trunk/vendor, they are also missing from the tagged release)

@joppuyo
Copy link
Author

joppuyo commented Nov 24, 2019

I was initially doing something similar like here by copying the release in its own directory but I changed the deployment to operate in the same directory because I read that a subdirectory is not supported by this action.

@joppuyo
Copy link
Author

joppuyo commented Nov 24, 2019

What do you mean by build code? The github actions workflow file lists all the commands I run: https://github.com/joppuyo/acf-image-aspect-ratio-crop/blob/v3.1.4/.github/workflows/main.yml .

I'm using gitignore to keep files like /node_modules, /assets/dist (css and js build files) and /vendor (composer) out of the repository.

I run composer install, npm install and npx webpack to create the build files during the deployment.

The idea behind deleting .git folder and some configuration files because I don't want them in the final repo. I don't use .gitattributes.

I think the main problem is that I don't keep the build files like js, css and composer dependencies in the repo and they are created during the github actions build process.

@helen
Copy link
Collaborator

helen commented Nov 24, 2019

Both assets/dist and vendor are in your .gitignore, which is why they're excluded from the deploy. If that's not what you want, then you will want to add a .distignore file with the files you don't want to include, which I imagine would include the items in rm -fr .github node_modules .travis.yml .editorconfig .gitignore .prettierrc.js deploy.sh deploy-github.sh tests, as well as .git, .distignore, and .wordpress-org. Here's an example .distignore file for a plugin that uses a build process and does not commit built files.

Looking at your overall build, I would probably recommend the following:

  • Create a separate workflow file for the tasks that run on tag rather than trying to keep everything in one workflow file so it's clearer what actually needs to run for that specific context. I get the appeal of using a single workflow, but IMO it's more confusing.
  • Assuming you want Packagist and .org to contain the same thing, create the zip after deploying to .org, using the contents of the SVN trunk directory, which would be /github/svn-${SLUG}/trunk, where ${SLUG} is either the repo name or what you've sent as an env variable. You can then also copy from that directory into your release repo.

@joppuyo
Copy link
Author

joppuyo commented Nov 24, 2019

Hey, thanks for looking over the repo, apologies it's a bit of a mess since this is the first time I'm trying out github actions.

the Insert Special Characters plugin has pretty much the same deployment process I'm looking for.

I still don't totally understand what causes the dist files to disappear with my plugin and not the one you linked? Maybe modifying the git repo with rm causes this issue?

I'll look into the .distignore since it seems to better achieve the same thing.

Thanks again!

@joppuyo
Copy link
Author

joppuyo commented Nov 24, 2019

I moved the wp.org deploy action right after the npm and composer build step and now the deployment is working perfectly.

I think modifying files in the git repo was the cause of my problems.

I'll have to refector the workflow later but this action is already definitely better than my old shell script contraption for deploying plugins to w.org.

Thanks!

@joppuyo joppuyo closed this as completed Nov 24, 2019
@helen
Copy link
Collaborator

helen commented Nov 25, 2019

@joppuyo No problem! I think I need to write out more detailed instructions and maybe a technical explanation since most WP plugin devs are just getting into using Actions and probably don't write a lot of Bash day-to-day.

The reason why your previous process was leaving out those files was because without a .distignore file in your repo, it falls back to the .gitattributes + .gitignore method to exclude things like .git, .github, and .wordpress-org. This method uses git archive to export the files to the SVN directory (the same way GitHub does for its generated zip actually) which means that anything in your .gitignore would not be included. If you have a .distignore, the Action uses rsync instead so it doesn't care about what Git does or doesn't know about, which works a lot better for build processes where you want Git to ignore built files.

One thing that I want to do for #4 is add an example workflow that generates a ZIP file and attaches it to the GitHub release for your tag, so if you don't get there first hopefully I will soon :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Something isn't working.
Projects
None yet
Development

No branches or pull requests

2 participants