Skip to content

Add GH action to push hydrogen theme to external repo #23

Add GH action to push hydrogen theme to external repo

Add GH action to push hydrogen theme to external repo #23

name: (main) push to external repo
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
push-to-external-repo:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Determine branch
id: branch
run: |
if [ "${{ github.event_name }}" == "pull_request" ]; then
pr_number="${{ github.event.number }}"
echo "branch=pull-request-${pr_number}" >> $GITHUB_OUTPUT
else
echo "branch=main" >> $GITHUB_OUTPUT
fi
- name: Check for changes in hydrogen-theme
id: check-changes
run: |
if git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep -q "^templates/hydrogen-theme/"; then
echo "HYDROGEN_THEME_CHANGED=true" >> $GITHUB_ENV
else
echo "HYDROGEN_THEME_CHANGED=false" >> $GITHUB_ENV
fi
- name: Publish to external repository
if: env.HYDROGEN_THEME_CHANGED == 'true'
uses: peaceiris/actions-gh-pages@v3
with:
deploy_key: ${{ secrets.SSH_DEPLOY_KEY }}
publish_dir: ./templates/hydrogen-theme
external_repository: ${{ vars.EXTERNAL_REPO }}
publish_branch: ${{ steps.branch.outputs.branch }}
allow_empty_commit: true