-
Notifications
You must be signed in to change notification settings - Fork 608
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add examples of useful GitHub Actions for theme development #1864
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
.github/workflow-examples/automatic_deployment_production.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# Deploy Theme to Store when new changes are pushed to master branch | ||
name: Deploy Theme to Store | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: [ master, main ] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
node: [12.x] | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Use Node.js ${{ matrix.node }} | ||
uses: actions/setup-node@v2-beta | ||
with: | ||
node-version: ${{ matrix.node }} | ||
|
||
- name: npm cache | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/.npm | ||
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | ||
restore-keys: | | ||
${{ runner.os }}-node- | ||
|
||
- name: Install Stencil CLI Dependency | ||
run: npm install -g @bigcommerce/stencil-cli | ||
|
||
- name: Install Dependencies | ||
run: npm ci | ||
|
||
# | ||
# You must configure store credentials as secrets on your GitHub repo for automatic deployment via GitHub Actions | ||
# | ||
|
||
- name: Connect to store | ||
env: | ||
URL: ${{ secrets.STENCIL_STORE_URL_PRODUCTION }} | ||
TOKEN: ${{ secrets.STENCIL_ACCESS_TOKEN_PRODUCTION }} | ||
run: stencil init -u $URL -t $TOKEN -p 3000 | ||
|
||
- name: Push theme live, automatically deleting oldest theme if necessary | ||
run: stencil push -a -d |
72 changes: 72 additions & 0 deletions
72
.github/workflow-examples/poll_for_changed_configuration.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# Create PRs for updated configurations caused by changes in Page Builder as a scheduled job. | ||
|
||
name: Check for updated configuration on production store | ||
|
||
on: | ||
workflow_dispatch: | ||
schedule: | ||
# Runs every 3 hours | ||
# * is a special character in YAML so you have to quote this string | ||
- cron: '0 */3 * * *' | ||
push: | ||
branches: [ master, main ] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
node: [12.x] | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Use Node.js ${{ matrix.node }} | ||
uses: actions/setup-node@v2-beta | ||
with: | ||
node-version: ${{ matrix.node }} | ||
|
||
- name: npm cache | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/.npm | ||
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | ||
restore-keys: | | ||
${{ runner.os }}-node- | ||
|
||
- name: Install Stencil CLI Dependency | ||
run: npm install -g @bigcommerce/stencil-cli | ||
|
||
# | ||
# You must configure store credentials as secrets on your GitHub repo for this job to work | ||
# | ||
|
||
- name: Connect to store | ||
env: | ||
URL: ${{ secrets.STENCIL_STORE_URL_PRODUCTION }} | ||
TOKEN: ${{ secrets.STENCIL_ACCESS_TOKEN_PRODUCTION }} | ||
run: stencil init -u $URL -t $TOKEN -p 3000 | ||
|
||
- name: Check for an updated configuration on the live store | ||
run: stencil pull | ||
|
||
- name: Create Pull Request | ||
id: cpr | ||
uses: peter-evans/create-pull-request@v3 | ||
with: | ||
delete-branch: true | ||
commit-message: Update config.json to match production store | ||
branch: configuration-sync | ||
title: 'Update config.json based on changes in Page Builder' | ||
body: | | ||
Changes were detected between your live store's Theme Configuration and config.json. | ||
|
||
These may have been due to changes made in Page Builder, or because a theme was uploaded to your store out of sync with your source control. | ||
|
||
By merging this PR, you can bring your local config.json in sync with the live store, and prevent issues where deploying your theme would overwrite recent changes. | ||
|
||
Note that this is checked every few hours, so it's possible changes made very recently are not accounted for. You may re-run this action again manually to make sure everything is up to date. | ||
labels: | | ||
automated pr |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to add a readme file as well in this repo to call out how to use it and how to setup some of these secrets ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I plan to get some public dev docs posted... can do another PR to add a link once we have those