Set up a Git repository for automatic deployments to your Managed WooCommerce Stores site
Using version control like GitHub for automatic deployments is a best practice. To minimize problems, make sure that your repository is configured correctly. Here are a couple of key concepts to keep in mind for automatic deployments from version control.
Mirror your production environment
At deployment time, everything on the destination site is changed to match what's in your Git repository. So when you first set up (or if you're upating) the repository, start by pulling a copy of your production code and pushing that code into the repository.
Exclude certain files from automatic deployments
There are a few kinds of files that you may need to exclude from automatic deployments:
WordPress core files to exclude
We handle all updates to WordPress core files automatically. So, to avoid committing those core files when you deploy, add these rules to your .gitignore file:
# Ignore WordPress core files*/ wp-content/advanced-cache.php wp-content/wp-cache-config.php sitemap.xml *.log /wp-*.php /index.php license.txt readme.html wp-admin/ wp-includes/ xmlrpc.php wp-content/cache/ wp-content/backups/ wp-content/mu-plugins/pagely* wp-config-hosting.php wp-config.php sitemap.xml.gz
Depending on how you've configured your site, there may be others you'll want to exclude as well. Be sure to check over your files and set up exclusions for anything unnecessary, such as cache and backup files.
In most scenarios where an entire site is being kept inside version control, the repository's root directory should only contain the wp-content directory.
Development files to exclude
Besides WordPress core files, you probably need to exclude files specific to your local development environment, as seen in this .gitignore example:
# Development environments .lando.yml .idea/ # Databases *.sql *.sql.gz *.sqlite # Logs *.log # Build files node_modules/ # Compressed files *.zip *.tar *.gz *.rar # OS files .DS_Store
You may need to add or remove some of these from this list. For any files that you need to have inside of your repository but don't want to deploy, you can exclude them on deployment as described in the next section.
Additional files to exclude
For files that you still need to have inside of your repository but don't want to deploy, integrations using our deployment Docker image allow you to set more exclusions. To do so, create a .pagely/pagelyignore file. This file ignores individual files or directories, relative to the repository's root, as in this example:
ignored-file.php wp-content/plugins/ignored-plugin-directory/***
Default file exclusions
When using our deployment integration system, these files are excluded by default:
/sitemap.xml /wp-*.php /index.php /wp-admin/*** /wp-includes/*** /xmlrpc.php /db-config.php /wp-content/index.php /wp-content/advanced-cache.php /wp-content/object-cache.php /wp-content/wp-cache-config.php /wp-content/uploads/*** /wp-content/blogs.dir/*** /wp-content/upgrade/*** /wp-content/backup-db/*** /wp-content/mu-plugins/index.php /wp-content/themes/index.php /wp-content/plugins/index.php /wp-content/languages/index.php /wp-content/mu-plugins/pagely-*/***
More info
- Learn how to create a Git integration for your Managed WooCommerce Stores site.
- Get details on setting up GitHub for automatic deployments to your site.