Skip to content

Sync from create-wordpress-plugin #242

Sync from create-wordpress-plugin

Sync from create-wordpress-plugin #242

name: Sync from create-wordpress-plugin
on:
schedule:
- cron: '0 4 * * *'
workflow_dispatch:
jobs:
sync:
runs-on: ubuntu-latest
env:
BRANCH_NAME: "sync/create-wordpress-plugin"
GH_TOKEN: ${{ secrets.PERSONAL_TOKEN }}
GITHUB_TOKEN: ${{ secrets.PERSONAL_TOKEN }}
SOURCE_REPO: "alleyinteractive/create-wordpress-plugin"
TARGET_REPO: "alleyinteractive/mantle"
steps:
- name: Checkout mantle repo
uses: actions/checkout@v4
with:
token: ${{ secrets.PERSONAL_TOKEN }}
fetch-depth: 0
- name: Checkout create-wordpress-plugin repo
uses: actions/checkout@v4
with:
repository: ${{ env.SOURCE_REPO }}
path: create-wordpress-plugin
token: ${{ secrets.PERSONAL_TOKEN }}
fetch-depth: 1
- name: Configure Git
run: |
git config user.name "mantle-bot"
git config user.email "[email protected]"
git checkout -B $BRANCH_NAME
- name: Copy selected files
run: |
files_to_copy=(
".editorconfig"
".github/workflows/all-pr-tests.yml"
".nvmrc"
".stylelintrc.json"
"babel.config.js"
"blocks/README.md"
"entries/README.md"
"jest.config.js"
"jsconfig.json"
"package-lock.json"
"package.json"
"phpunit.xml"
"tsconfig.eslint.json"
"tsconfig.json"
)
for file in "${files_to_copy[@]}"; do
if [[ ! -f "create-wordpress-plugin/$file" ]]; then
echo "$file does not exist, deleting from source..."
rm -rf "$file" || true
else
dir=$(dirname "$file")
mkdir -p "$dir"
cp "create-wordpress-plugin/$file" "$file"
fi
done
- name: Modify package.json
run: |
sed -i 's/create-wordpress-plugin/mantle/g' package.json
sed -i 's/create-wordpress-plugin/mantle/g' package-lock.json
- name: Commit changes
run: |
rm -rf create-wordpress-plugin
git add -N .
if ! git diff --quiet; then
git add .
git commit -m "chore(sync): update files from create-wordpress-plugin"
git push --force --set-upstream origin $BRANCH_NAME
else
echo "No changes to commit."
fi
- name: Create PR if it doesn't exist
run: |
gh pr create \
--repo "$TARGET_REPO" \
--base main \
--head "$BRANCH_NAME" \
--title "chore(sync): update files from create-wordpress-plugin" \
--body "This PR syncs changes from the create-wordpress-plugin repository." || echo "Pull request creation failed."
env:
GH_TOKEN: ${{ secrets.PERSONAL_TOKEN }}