diff --git a/.github/workflows/shopify_deploy.yml b/.github/workflows/shopify_deploy.yml new file mode 100644 index 0000000..9669f89 --- /dev/null +++ b/.github/workflows/shopify_deploy.yml @@ -0,0 +1,70 @@ +name: Deploy to Shopify + +on: + workflow_call: + inputs: + working-directory: + description: 'Working directory for the app' + required: false + type: string + default: '.' + deploy-production: + description: "Boolean to check if deploy to production" + type: boolean + default: false + development-toml-name: + description: 'Name of development.toml' + required: false + type: string + default: 'shopify.app.development.toml' + production-toml-name: + description: 'Name of .toml' + required: false + type: string + default: 'shopify.app.toml' + + secrets: + shopify_cli_token: + description: 'Shopify CLI authentication token' + required: true + +jobs: + deploy: + name: Deploy to Shopify + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v5 + + - name: Setup Node.js + uses: actions/setup-node@v6 + with: + node-version-file: '.nvmrc' + cache: 'yarn' + cache-dependency-path: ${{ inputs.working-directory }}/yarn.lock + + - name: Install dependencies + working-directory: ${{ inputs.working-directory }} + run: yarn install --frozen-lockfile + + - name: Download build artifacts + uses: actions/download-artifact@v6 + with: + name: build-artifacts + path: ${{ inputs.working-directory }} + + - name: Configure Shopify CLI + working-directory: ${{ inputs.working-directory }} + run: | + if [ "${{ inputs.deploy-production }}" = "true" ]; then + yarn shopify app config use ${{ inputs.production-toml-name }} + else + yarn shopify app config use ${{ inputs.development-toml-name }} + fi + + - name: Deploy to Shopify + working-directory: ${{ inputs.working-directory }} + run: yarn shopify app deploy --force + env: + SHOPIFY_CLI_TOKEN: ${{ secrets.shopify_cli_token }} + SHOPIFY_FLAG_PATH: ${{ inputs.working-directory }} \ No newline at end of file diff --git a/README.md b/README.md index 42487fa..8a569c5 100644 --- a/README.md +++ b/README.md @@ -31,11 +31,11 @@ A streamlined AWS CDK deployment workflow supporting multi-environment infrastru | **Advanced Configuration** | | context-values | ❌ | string | {} | CDK context values as JSON object | | debug | ❌ | boolean | false | Enable verbose logging and debug output | +| aws-access-key-id | ✅ | | | AWS access key ID | #### **Secrets** | Name | Required | Description | |------|----------|-------------| -| aws-access-key-id | ✅ | AWS access key ID | | aws-secret-access-key | ✅ | AWS secret access key | | cfn-execution-role | ❌ | CloudFormation execution role ARN (optional, for cross-account deployments) | @@ -56,7 +56,7 @@ jobs: cdk-stack-name: my-app-dev environment-target: development secrets: - aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-access-key-id: ${{ vars.AWS_ACCESS_KEY_ID }} aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} ``` @@ -70,7 +70,7 @@ jobs: environment-target: production debug: true secrets: - aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-access-key-id: ${{ vars.AWS_ACCESS_KEY_ID }} aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} cfn-execution-role: ${{ secrets.CFN_EXECUTION_ROLE }} ``` @@ -86,7 +86,7 @@ jobs: bootstrap-stack: true aws-region: us-east-1 secrets: - aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-access-key-id: ${{ vars.AWS_ACCESS_KEY_ID }} aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} ``` @@ -100,7 +100,7 @@ jobs: environment-target: staging context-values: '{"vpc-id": "vpc-12345", "environment": "staging"}' secrets: - aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-access-key-id: ${{ vars.AWS_ACCESS_KEY_ID }} aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} ``` @@ -546,3 +546,65 @@ jobs: secrets: gadget-api-token: ${{ secrets.GADGET_API_TOKEN }} ``` + +### Shopify App Deployment + +A streamlined Shopify app deployment workflow supporting both development and production environments with automatic configuration management. + +#### **Features** +- **Multi-environment support**: development and production deployments via `deploy-production` flag +- **Configuration management**: Automatic selection of environment-specific TOML files +- **Build artifact integration**: Downloads and deploys pre-built artifacts +- **Node.js version control**: Automatic detection from .nvmrc file with Yarn caching +- **Force deployment**: Ensures deployment proceeds without manual prompts + +#### **Inputs** +| Name | Required | Type | Default | Description | +|------|----------|------|---------|-------------| +| **Deployment Configuration** | +| deploy-production | ❌ | boolean | false | Boolean to check if deploying to production | +| working-directory | ❌ | string | . | Working directory for the app | +| **Shopify Configuration** | +| development-toml-name | ❌ | string | shopify.app.development.toml | Development TOML configuration file name | +| production-toml-name | ❌ | string | shopify.app.toml | Production TOML configuration file name | + +#### **Secrets** +| Name | Required | Description | +|------|----------|-------------| +| shopify_cli_token | ✅ | Shopify CLI authentication token | + +#### **Example Usage** + +**Development Deployment:** +```yaml +jobs: + deploy-dev: + uses: aligent/workflows/.github/workflows/shopify_deploy.yml@main + secrets: + shopify_cli_token: ${{ secrets.SHOPIFY_CLI_TOKEN }} +``` + +**Production Deployment:** +```yaml +jobs: + deploy-prod: + uses: aligent/workflows/.github/workflows/shopify_deploy.yml@main + with: + deploy-production: true + secrets: + shopify_cli_token: ${{ secrets.SHOPIFY_CLI_TOKEN }} +``` + +**Custom Configuration:** +```yaml +jobs: + deploy-custom: + uses: aligent/workflows/.github/workflows/shopify_deploy.yml@main + with: + deploy-production: true + working-directory: ./my-shopify-app + development-toml-name: shopify.app.dev.toml + production-toml-name: shopify.app.prod.toml + secrets: + shopify_cli_token: ${{ secrets.SHOPIFY_CLI_TOKEN }} +``` \ No newline at end of file