Skip to content

Commit

Permalink
feat: try fix
Browse files Browse the repository at this point in the history
  • Loading branch information
zugdev committed Nov 8, 2024
1 parent 5f114c8 commit 5bcec37
Showing 1 changed file with 11 additions and 24 deletions.
35 changes: 11 additions & 24 deletions .github/workflows/sync-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,8 @@ jobs:
with:
fetch-depth: 0

# - name: Get GitHub App token
# uses: tibdex/github-app-token@v1.7.0
# id: get_installation_token
# with:
# app_id: ${{ secrets.APP_ID }}
# private_key: ${{ secrets.APP_PRIVATE_KEY }}

- name: Sync branch to template
env:
# GH_TOKEN: ${{ steps.get_installation_token.outputs.token }}
WHITELIST_FILES: ".github/workflows/build.yml tsconfig.json"
ADDITIONAL_FILES: ${{ github.event.inputs.additional_files }}
run: |
Expand All @@ -50,32 +42,27 @@ jobs:
git clone https://github.com/zugdev/ts-template template-repo
# Convert ADDITIONAL_FILES input to an array
additional_files=""
additional_files=()
if [[ -n "$ADDITIONAL_FILES" ]]; then
IFS=',' read -r -a additional_files <<< "$ADDITIONAL_FILES"
fi
# Copy whitelist files from template
for file in $WHITELIST_FILES; do
if [[ -e "template-repo/$file" ]]; then
cp -rf "template-repo/$file" "$file"
done
# Copy additional files from template (if any were specified)
for file in "${additional_files[@]}"; do
if [[ -e "template-repo/$file" ]]; then
cp -rf "template-repo/$file" "$file"
done
# Prepare a formatted file list for the PR body
# Prepare file list for the PR body and process each whitelist file
file_list=""
for file in $WHITELIST_FILES "${additional_files[@]}"; do
file_list+="\n- \`${file}\`"
if [[ -e "template-repo/$file" ]]; then
cp -rf "template-repo/$file" "$file"
file_list+="\n- \`${file}\`"
else
# Remove file from destination if not in template
rm -rf "$file"
file_list+="\n- \`${file}\` (removed)"
fi
done
# Clean up
rm -rf template-repo/
git add .
git commit -m "chore: sync template"
git push "$original_remote" "$pr_branch"
gh pr create --title "Sync branch to template" --body "This pull request merges changes from the template repository, overwriting the following files:${file_list}" --head "$pr_branch" --base "$branch_name"
gh pr create --title "Sync branch to template" --body "This pull request merges changes from the template repository, overwriting or removing the following files:${file_list}" --head "$pr_branch" --base "$branch_name"

0 comments on commit 5bcec37

Please sign in to comment.