This repository contains a script that automatically sets Shopify products without images (either product or variant images) to draft status. The script is configured to run daily via GitHub Actions.
- The script uses the Shopify API to fetch all products from your store
- It checks each product to see if it has any images (either product-level or variant-level)
- Any published product without images is set to draft status
- The script runs automatically once per day via GitHub Actions
- Log in to your Shopify admin panel
- Go to Apps > Develop apps
- Click "Create an app"
- Give the app a name (e.g., "Draft Products Automation")
- Configure the app with Admin API access
- Set necessary scopes:
read_productswrite_products
- Install the app in your store
- Save the API key, API secret key, and your shop name
Add the following secrets to your GitHub repository:
SHOPIFY_SHOP_NAME: Your shop name (example: your-store.myshopify.com)SHOPIFY_API_KEY: The API key from your Shopify appSHOPIFY_ADMIN_API_TOKEN: The admin access token from your Shopify app
- Clone this repository
- Push to your own GitHub repository
- The GitHub Action will automatically run on schedule (2:00 AM UTC daily)
- You can also manually trigger the workflow from the "Actions" tab
If you want to run the script locally:
- Clone the repository
- Create a
.envfile with the following content:SHOPIFY_SHOP_NAME=your-store.myshopify.com SHOPIFY_API_KEY=your_api_key SHOPIFY_ADMIN_API_TOKEN=your_admin_api_token - Install dependencies:
npm install - Run the script:
npm start
- To change the schedule, edit the cron expression in
.github/workflows/shopify-draft-products.yml - To modify the script behavior, edit
script.js
If you encounter issues:
- Check the GitHub Actions logs for detailed error messages
- Verify your Shopify API credentials are correct
- Make sure your API app has the necessary permissions
- Check if you've hit Shopify API rate limits (current implementation includes basic pagination to handle large stores)