first load
This commit is contained in:
128
.github/workflows/sync_repo.yml
vendored
Normal file
128
.github/workflows/sync_repo.yml
vendored
Normal file
@@ -0,0 +1,128 @@
|
||||
name: Sync Repo
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
schedule:
|
||||
- cron: '38 */12 * * *'
|
||||
|
||||
jobs:
|
||||
sync:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
actions: write # needed to call other workflows
|
||||
steps:
|
||||
- name: Checkout your repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
ref: main
|
||||
repository: ivancarlosti/copenlight
|
||||
clean: true
|
||||
persist-credentials: true
|
||||
|
||||
- name: Reset Git remote
|
||||
run: |
|
||||
git remote remove origin || true
|
||||
git remote add origin https://github.com/ivancarlosti/copenlight.git
|
||||
git remote -v
|
||||
|
||||
- name: Download CopenhagenTheme content (from master)
|
||||
run: |
|
||||
mkdir -p /tmp/copenhagen_temp
|
||||
cd /tmp/copenhagen_temp
|
||||
git clone --branch master https://github.com/zendesk/copenhagen_theme.git
|
||||
echo "== Checking manifest.json version =="
|
||||
MANIFEST="/tmp/copenhagen_temp/copenhagen_theme/manifest.json"
|
||||
if [ ! -f "$MANIFEST" ]; then
|
||||
echo "No manifest.json file found, aborting sync."
|
||||
exit 0
|
||||
fi
|
||||
cat "$MANIFEST"
|
||||
VERSION=$(jq -r '.version // empty' "$MANIFEST")
|
||||
if [ -z "$VERSION" ]; then
|
||||
echo "No version defined in manifest.json, aborting sync."
|
||||
exit 0
|
||||
fi
|
||||
if echo "$VERSION" | grep -i 'beta'; then
|
||||
echo "Version is beta ($VERSION), aborting sync."
|
||||
exit 0
|
||||
fi
|
||||
echo "Version is $VERSION. Proceeding with sync."
|
||||
rsync -av \
|
||||
--exclude='.github' \
|
||||
--exclude='.git' \
|
||||
--exclude='README.md' \
|
||||
--exclude='LICENSE' \
|
||||
/tmp/copenhagen_temp/copenhagen_theme/ "$GITHUB_WORKSPACE/"
|
||||
|
||||
- name: Debug manifest.json in workspace
|
||||
run: |
|
||||
echo "= manifest.json in your repo after sync ="
|
||||
cat "$GITHUB_WORKSPACE/manifest.json" || echo "manifest.json missing!"
|
||||
|
||||
- name: Modify manifest.json
|
||||
run: |
|
||||
echo "== Updating manifest.json with custom name and author =="
|
||||
MANIFEST="$GITHUB_WORKSPACE/manifest.json"
|
||||
if [ -f "$MANIFEST" ]; then
|
||||
jq '.name = "CopenLight" | .author = "Ivan Carlos"' "$MANIFEST" > "$MANIFEST.tmp" && mv "$MANIFEST.tmp" "$MANIFEST"
|
||||
echo "Updated manifest.json:"
|
||||
cat "$MANIFEST"
|
||||
else
|
||||
echo "manifest.json not found!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Append custom CSS from template
|
||||
run: |
|
||||
STYLE_CSS="$GITHUB_WORKSPACE/style.css"
|
||||
CUSTOM_CSS="$GITHUB_WORKSPACE/custom/style.css.template"
|
||||
if [ -f "$STYLE_CSS" ] && [ -f "$CUSTOM_CSS" ]; then
|
||||
echo "== Appending custom CSS from template to style.css =="
|
||||
echo "" >> "$STYLE_CSS"
|
||||
echo "/* ### BEGIN part to custom style from template ### */" >> "$STYLE_CSS"
|
||||
cat "$CUSTOM_CSS" >> "$STYLE_CSS"
|
||||
echo "/* ### END part to custom style from template ### */" >> "$STYLE_CSS"
|
||||
echo "Custom CSS appended successfully."
|
||||
else
|
||||
echo "Either style.css or style.css.template not found!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Append custom JS from template
|
||||
run: |
|
||||
SCRIPT_JS="$GITHUB_WORKSPACE/script.js"
|
||||
CUSTOM_JS="$GITHUB_WORKSPACE/custom/script.js.template"
|
||||
if [ -f "$SCRIPT_JS" ] && [ -f "$CUSTOM_JS" ]; then
|
||||
echo "== Appending custom JS from template to script.js =="
|
||||
echo "" >> "$SCRIPT_JS"
|
||||
echo "/* ### BEGIN part to custom JS from template ### */" >> "$SCRIPT_JS"
|
||||
cat "$CUSTOM_JS" >> "$SCRIPT_JS"
|
||||
echo "/* ### END part to custom JS from template ### */" >> "$SCRIPT_JS"
|
||||
echo "Custom JS appended successfully."
|
||||
else
|
||||
echo "Either script.js or script.js.template not found!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Cleanup temp files
|
||||
run: rm -rf /tmp/copenhagen_temp
|
||||
|
||||
- name: Commit changes
|
||||
id: commit_step
|
||||
run: |
|
||||
cd "$GITHUB_WORKSPACE"
|
||||
git config --global user.email "ivan@ivancarlos.com.br"
|
||||
git config --global user.name "ivancarlosti"
|
||||
git add .
|
||||
if git diff-index --quiet HEAD --; then
|
||||
echo "No changes to commit"
|
||||
echo "changes_committed=false" >> $GITHUB_OUTPUT
|
||||
else
|
||||
git commit -m "Sync CopenhagenTheme content [▶️]"
|
||||
echo "Commit created"
|
||||
git push https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/ivancarlosti/copenlight.git HEAD:main
|
||||
echo "Push successful"
|
||||
echo "changes_committed=true" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
Reference in New Issue
Block a user