shopify-theme-actions
Shopify Theme Actions
A set of GitHub Actions to enable fast Shopify theme development/review workflows, options:
- Create & deploy a PR specific preview theme when a PR is opened/updated
- Remove the PR specific preview theme once the PR is closed
- Deploy a specified theme when a PR is opened/updated
- Deploy to a specified Shopify theme once commits are pushed into a branch i.e. deploy to production
PR Comments
After any deployment, if GITHUB_TOKEN
is set & the deployment was triggered by a PR, a comment will be added to the PR with a link to view the Shopify theme preview (as above).
Get Started
-
Create a Shopify Private App with the permissions
Themes: Read and write
. -
Add the Shopify Private App credentials as the Github secrets;
SHOPIFY_PASSWORD
,SHOPIFY_API_KEY
andSHOPIFY_STORE_URL
(i.e.mystore.myshopify.com
) -
If you do not have the folders already create a
.github
folder with aworkflows
folder inside -
within this
./github/workflows/
folder add any of the below theme development/review workflows; When a:
- PR is opened/updated create and deploy a PR specific Shopify theme
- PR is closed remove the previously created PR specific Shopify theme
- PR is opened/updated deploy to a specified theme i.e. testing/staging theme
-
commmit is pushed to the
main
branch deploy to production
Requirements
Requires a Shopify Private App to be created with the permissions: Themes: Read and write
Inputs
Github action inputs:
ACTION
required
-
DEPLOYMENT_PREVIEW
Creates a new Shopify theme for each PR raised. If a PR specific theme already exists it will be updated (i.e. on agit push
after the PR was created). -
REMOVE_DEPLOYMENT_PREVIEW_THEME
Removes a previously created PR specific Shopify theme that was created whenACTION
was set toDEPLOYMENT_PREVIEW
-
DEPLOY
Deploys to the specified Shopify theme, useful for definedtesting
/staging
/production
themes.SHOPIFY_THEME_ID
must be set.
If deploying to the live Shopify stores theme make sure to setSHOPIFY_ALLOW_LIVE_THEME_DEPLOYMENT
totrue
SHOPIFY_STORE_URL
required
The shopify development store i.e. my-store.myshopify.com
Should be stored as a GitHub secret!
SHOPIFY_PASSWORD
required
The Shopify store’s private app password used with themekit
Should be stored as a GitHub secret!
SHOPIFY_API_KEY
required
The Shopify store’s private app API Key to allow theme creation and removal
Should be stored as a GitHub secret!
SHOPIFY_THEME_DIRECTORY
required
The directory containing the Shopify theme to deploy i.e. ./dist
SHOPIFY_THEME_ID
optional
The Shopify theme that will be deployed to (only used if ‘ACTION’ is ‘DEPLOY’)
SHOPIFY_ALLOW_LIVE_THEME_DEPLOYMENT
optional
If deploying to a ‘live’ (published) Shopify theme this must be set to true
IGNORED_FILES
optional
Ignore files pattern. Comma seperated string of patterns / file paths.
GITHUB_TOKEN
optional
Github authentication token that allows comments to be created on PRs.
If not set comments cannot be created on PRs and previously created PR specific Shopify themes cannot be removed.
Outputs
Github action outputs (can be used in following steps):
SHOPIFY_THEME_ID
The newly created/found/supplied Shopify theme id
SHOPIFY_THEME_PREVIEW_URL
The URL the theme can be previewed at
License
Shopify Theme Actions is MIT licensed.