Skip to content

Actions and extensions for Shopify stores

Notifications You must be signed in to change notification settings

gzeta-adv/shopify

Repository files navigation

Shopify

This repository contains the source code of the actions, extensions and APIs used by the GZETA Shopify stores.

Setup

Download the repository and install the dependencies:

pnpm install

Copy the .env.example file to .env and fill in the necessary environment variables depending on the actions you want to run.

Actions

To run an action, use the command:

pnpm run action <workflow-name>

Each action is run with a GitHub Actions workflow defined in the .github/workflows directory and needs specific environment variables. All actions can be triggered manually via the Run workflow button in the repository Actions tab.

Sync Collections Status

The action synchronizes the publications of a Shopify collection depending on a given metafield and logs the operations in a Google Sheets spreadsheet.

Workflow Environment Schedule Logs
sync-collections-status GOOGLE_SHEETS_CLIENT_EMAIL
GOOGLE_SHEETS_PRIVATE_KEY
GOOGLE_SHEETS_SPREADSHEET_ID
GOOGLE_SHEETS_SYNC_COLLECTIONS_STATUS_SHEET
SHOPIFY_ACCESS_TOKEN
SHOPIFY_STORE_ID
Every 3 hours Collection Status Operations

Sync Products Quantity

The action synchronizes the quantity of the products in a customer PIM with the quantity in the Shopify store and logs the operations in a Google Sheets spreadsheet.

Workflow Environment Schedule Logs
sync-products-quantity GOOGLE_SHEETS_CLIENT_EMAIL
GOOGLE_SHEETS_PRIVATE_KEY
GOOGLE_SHEETS_SPREADSHEET_ID
GOOGLE_SHEETS_SYNC_PRODUCTS_QUANTITY_SHEET
PIM_API_URL
PIM_API_KEY
PIM_VERIFY_ENDPOINT
RETRIES (optional)
SHOPIFY_ACCESS_TOKEN
SHOPIFY_LOCATION_ID
SHOPIFY_STORE_ID
Every minute* Product Quantity Operations

Notes

Run workflows in shorter intervals

GitHub Actions has a limit of 5 minutes for intervals between workflow runs. To run a workflow every minute, the action needs a repository_dispatch event, which can be triggered with the following HTTP request:

curl --request POST \
  --url 'https://api.github.com/repos/gzeta-adv/shopify/dispatches' \
  --header 'authorization: Bearer <GITHUB_ACCESS_TOKEN>' \
  --data '{ "event_type": "Sync products quantity" }'

The service currently used to send requests every minute is Google Cloud Scheduler.