From 5bcec3764d8650c70b7acfc348b10c5d2c3927cd Mon Sep 17 00:00:00 2001 From: zugdev Date: Fri, 8 Nov 2024 18:48:57 -0300 Subject: [PATCH] feat: try fix --- .github/workflows/sync-template.yml | 35 +++++++++-------------------- 1 file changed, 11 insertions(+), 24 deletions(-) diff --git a/.github/workflows/sync-template.yml b/.github/workflows/sync-template.yml index d94424c..3ee8eb2 100644 --- a/.github/workflows/sync-template.yml +++ b/.github/workflows/sync-template.yml @@ -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: | @@ -50,27 +42,22 @@ 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 @@ -78,4 +65,4 @@ jobs: 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" \ No newline at end of file + 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" \ No newline at end of file