Skip to content

Commit

Permalink
Test commit 22
Browse files Browse the repository at this point in the history
  • Loading branch information
phapsidesGT committed Sep 4, 2024
1 parent 58a7de0 commit 2d48b4e
Showing 1 changed file with 23 additions and 57 deletions.
80 changes: 23 additions & 57 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
@@ -1,66 +1,32 @@
name: Deploy Shopify Theme
name: CI/CD Pipeline for Shopify

on:
push:
branches:
- main
- feature/github-actions # Replace with your branch name as needed
- feature/github-actions # Change 'feature/github-actions' to main

jobs:
deploy:
name: Deploy to Shopify Store
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Install Shopify CLI Dependencies
run: |
sudo apt-get update
sudo apt-get install -y ruby-full ruby-bundler ruby-dev build-essential
- name: Install Shopify CLI
run: |
echo "Installing Shopify CLI..."
gem install --user-install shopify-cli
# Dynamically add Ruby Gems to PATH
echo "PATH=$(ruby -e 'print Gem.user_dir')/bin:$PATH" >> $GITHUB_ENV
- name: Deploy to Shopify
env:
SHOPIFY_PASSWORD: ${{ secrets.SHOPIFY_PASSWORD }}
SHOPIFY_STORE: ${{ secrets.SHOPIFY_STORE }}
THEME_ID: ${{ secrets.THEME_ID }}
run: |
# Load the updated PATH
source $GITHUB_ENV
# Check Shopify CLI version
shopify version
# Configure Shopify CLI
shopify config set store "$SHOPIFY_STORE"
shopify config set password "$SHOPIFY_PASSWORD"
# Retry logic to push theme to Shopify store
attempt=0
max_attempts=5
delay=1
while [ $attempt -lt $max_attempts ]; do
echo "Pushing theme (Attempt: $((attempt + 1))/$max_attempts)..."
if shopify theme push --store "$SHOPIFY_STORE" --password "$SHOPIFY_PASSWORD" --theme "$THEME_ID" --allow-live; then
echo "Theme pushed successfully."
break
else
echo "Error encountered. Retrying in $delay seconds..."
sleep $delay
attempt=$((attempt + 1))
delay=$((delay * 2)) # Exponential backoff
fi
done
if [ $attempt -eq $max_attempts ]; then
echo "Failed to push theme after $max_attempts attempts."
exit 1
fi
- uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '14'

- name: Install Shopify CLI
run: npm install -g @shopify/cli @shopify/theme

- name: Authenticate Shopify CLI
env:
SHOPIFY_CLI_AUTH_TOKEN: ${{ secrets.SHOPIFY_CLI_AUTH_TOKEN }}
run: echo $SHOPIFY_CLI_AUTH_TOKEN | shopify login --store ${{ secrets.SHOPIFY_STORE_URL }} --password-stdin

- name: Deploy Theme to Shopify
env:
SHOPIFY_STORE_URL: ${{ secrets.SHOPIFY_STORE_URL }}
SHOPIFY_THEME_ID: ${{ secrets.SHOPIFY_THEME_ID }}
run: shopify theme push --allow-live --store=${{ secrets.SHOPIFY_STORE_URL }} --theme=${{ secrets.SHOPIFY_THEME_ID }}

0 comments on commit 2d48b4e

Please sign in to comment.