From ffcb627317b0436bf8f265321740fc743b5d558a Mon Sep 17 00:00:00 2001 From: kirill ivanov Date: Sat, 29 Mar 2025 07:30:23 +0300 Subject: [PATCH 01/22] feat(github): workflow sync feat(github): useless feat(github): useless feat(github): useless feat(github): useless feat(github): useless feat(github): useless --- .github/workflows/synchronization.yaml | 115 +++++++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 .github/workflows/synchronization.yaml diff --git a/.github/workflows/synchronization.yaml b/.github/workflows/synchronization.yaml new file mode 100644 index 00000000..a3257f31 --- /dev/null +++ b/.github/workflows/synchronization.yaml @@ -0,0 +1,115 @@ +name: PersonaClick Synchronization + +env: + TERGET_REPO: "PersonaClick/workflow" + MANAGER_USERNAME: TorinAsakura + +on: + pull_request: + types: + - closed + branches: + - master + workflow_dispatch: + +jobs: + run: + if: github.event.pull_request.merged == true + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + path: source + env: + GITHUB_TOKEN: ${{ secrets.JADE_SMITH_BOT_TOKEN }} + + - name: Check out remote repository + uses: actions/checkout@v4 + with: + repository: ${{ env.TERGET_REPO }} + token: ${{ secrets.JADE_SMITH_BOT_TOKEN }} + path: target + + - name: Clean target directory except excluded files + working-directory: target + run: | + find . -mindepth 1 -maxdepth 1 \ + ! -name ".git" \ + ! -name ".idea" \ + ! -name ".gitignore" \ + ! -name "LICENSE" \ + -exec rm -rf {} + + + - name: Sync files to remote repository + run: | + # TODO need to separete .github/workflows/synchronization.yaml into personal directory + rsync -av --progress \ + source/ target/ \ + --exclude '.git' \ + --exclude '.idea' \ + --exclude '.gitignore' \ + --exclude 'LICENSE' \ + --exclude '.github/workflows/synchronization.yaml' \ + + - name: Apply changes to files + working-directory: target + run: | + find . -type f \( -name '*.ts' -o -name '*.sh' -o -name '*.yaml' \) -exec sed -i \ + -e 's|https://api.rees46.com/|https://api.personaclick.com/|g' \ + -e 's/com.rees46:rees46-sdk/com.personaclick:personaclick-sdk/g' \ + -e 's/api.rees46.com/api.personaclick.com/g' \ + -e 's/rees46.com/personaclick.com/g' \ + -e 's/rees46/personaClick/g' \ + -e 's/REES46/PersonaClick/g' \ + -e 's/Rees46/PersonaClick/g' {} + + + - name: Get last merged PR author login + working-directory: source + id: pr_author + run: | + PR_NUMBER=$(gh pr list --state merged --limit 1 --json number --jq '.[0].number') + LAST_PR_AUTHOR=$(gh pr view $PR_NUMBER --json author --jq '.author.login') + echo "LAST_PR_AUTHOR=$LAST_PR_AUTHOR" >> $GITHUB_OUTPUT + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Create commit + working-directory: target + run: | + git config --global user.name Jade Smith + git config --global user.email github-bot@rees46.com + git add . + echo "Changes to be committed:" + git diff --staged + git commit -m "feat: release" + env: + GITHUB_TOKEN: ${{ secrets.JADE_SMITH_BOT_TOKEN }} + + - name: Set branch name + id: branch_name + run: echo "BRANCH_NAME=feat/new-release-$(date +%Y%m%d%H%M%S)" >> $GITHUB_OUTPUT + + - name: Checkout new branch and push + working-directory: target + run: | + git checkout -b $BRANCH_NAME + git push --set-upstream origin $BRANCH_NAME + env: + GITHUB_TOKEN: ${{ secrets.JADE_SMITH_BOT_TOKEN }} + BRANCH_NAME: ${{ steps.branch_name.outputs.BRANCH_NAME }} + + - name: Create Pull Request + working-directory: target + run: | + PR_TITLE="Automated release" + PR_BODY="This is an automated pull request to update from branch $BRANCH_NAME" + DEFAULT_BRANCH=$(gh repo view --json defaultBranchRef -q ".defaultBranchRef.name") + echo "Assigning PR to LAST_PR_AUTHOR: $LAST_PR_AUTHOR" + echo "Adding MANAGER: $MANAGER as a reviewer" + gh pr create --title "$PR_TITLE" --body "$PR_BODY" --base "$DEFAULT_BRANCH" --head $BRANCH_NAME --assignee $LAST_PR_AUTHOR --reviewer $MANAGER + env: + GITHUB_TOKEN: ${{ secrets.JADE_SMITH_BOT_TOKEN }} + BRANCH_NAME: ${{ steps.branch_name.outputs.BRANCH_NAME }} + LAST_PR_AUTHOR: ${{ steps.pr_author.outputs.LAST_PR_AUTHOR }} + MANAGER: ${{ env.MANAGER_USERNAME }} From bd5cd1e51529b9f0f8cd858f1a072aa40578b4bc Mon Sep 17 00:00:00 2001 From: kirill ivanov Date: Sun, 30 Mar 2025 19:03:45 +0300 Subject: [PATCH 02/22] refactor(github): separate variables refactor(github): useless refactor(github): useless refactor(github): useless refactor(github): useless refactor(github): useless refactor(github): useless refactor(github): useless refactor(github): useless refactor(github): useless refactor(github): useless refactor(github): useless refactor(github): useless refactor(github): useless refactor(github): useless refactor(github): useless refactor(github): useless refactor(github): useless refactor(github): useless refactor(github): useless refactor(github): useless refactor(github): useless refactor(github): useless refactor(github): useless refactor(github): useless refactor(github): useless refactor(github): useless refactor(github): useless refactor(github): useless refactor(github): useless refactor(github): useless refactor(github): useless refactor(github): useless refactor(github): useless refactor(github): useless refactor(github): useless refactor(github): useless refactor(github): useless refactor(github): useless refactor(github): useless refactor(github): useless refactor(github): useless refactor(github): useless refactor(github): useless refactor(github): useless refactor(github): useless refactor(github): useless refactor(github): useless refactor(github): useless refactor(github): useless refactor(github): useless refactor(github): useless refactor(github): useless refactor(github): useless refactor(github): useless refactor(github): useless refactor(github): useless refactor(github): useless refactor(github): useless refactor(github): useless refactor(github): useless --- .github/workflows/synchronization.yaml | 77 ++++++++++++++++---------- 1 file changed, 49 insertions(+), 28 deletions(-) diff --git a/.github/workflows/synchronization.yaml b/.github/workflows/synchronization.yaml index a3257f31..4795795e 100644 --- a/.github/workflows/synchronization.yaml +++ b/.github/workflows/synchronization.yaml @@ -3,18 +3,24 @@ name: PersonaClick Synchronization env: TERGET_REPO: "PersonaClick/workflow" MANAGER_USERNAME: TorinAsakura + SYNC_IGNORE: ".git,.idea,.gitignore,LICENSE,.github/workflows/synchronization.yaml" + REPLACMENT_EXTENTIONS: "*.ts,*.sh,*.yaml" + REPLACEMENT_CONTENTS: "https://api.rees46.com/|https://api.personaclick.com/,com.rees46:rees46-sdk|com.personaclick:personaclick-sdk,api.rees46.com|api.personaclick.com,rees46.com|personaclick.com,rees46|personaClick,REES46|PersonaClick,Rees46|PersonaClick" on: + # TODO uncomment pull_request: - types: - - closed - branches: - - master - workflow_dispatch: + # pull_request: + # types: + # - closed + # branches: + # - master + # workflow_dispatch: jobs: run: - if: github.event.pull_request.merged == true + # TODO uncomment + # if: github.event.pull_request.merged == true || github.event_name == 'workflow_dispatch' runs-on: ubuntu-latest steps: - name: Checkout @@ -34,35 +40,50 @@ jobs: - name: Clean target directory except excluded files working-directory: target run: | - find . -mindepth 1 -maxdepth 1 \ - ! -name ".git" \ - ! -name ".idea" \ - ! -name ".gitignore" \ - ! -name "LICENSE" \ - -exec rm -rf {} + + IFS=',' read -r -a ignored_files <<< "$SYNC_IGNORE" + exclude_conditions="" + for ignored_file in "${ignored_files[@]}"; do + exclude_conditions=" $exclude_conditions ! -name \"$ignored_file\"" + done + + eval find . -mindepth 1 -maxdepth 1 $exclude_conditions -exec rm -rf {} + + + # TODO need to separete .github/workflows/synchronization.yaml into personal directory - name: Sync files to remote repository run: | - # TODO need to separete .github/workflows/synchronization.yaml into personal directory - rsync -av --progress \ - source/ target/ \ - --exclude '.git' \ - --exclude '.idea' \ - --exclude '.gitignore' \ - --exclude 'LICENSE' \ - --exclude '.github/workflows/synchronization.yaml' \ + IFS=',' read -r -a ignored_files <<< "$SYNC_IGNORE" + + exclude_conditions="" + for ignored_file in "${ignored_files[@]}"; do + exclude_conditions=" $exclude_conditions --exclude \"$ignored_file\"" + done + + echo $exclude_conditions + + eval rsync -av --progress source/ target/ $exclude_conditions - name: Apply changes to files working-directory: target run: | - find . -type f \( -name '*.ts' -o -name '*.sh' -o -name '*.yaml' \) -exec sed -i \ - -e 's|https://api.rees46.com/|https://api.personaclick.com/|g' \ - -e 's/com.rees46:rees46-sdk/com.personaclick:personaclick-sdk/g' \ - -e 's/api.rees46.com/api.personaclick.com/g' \ - -e 's/rees46.com/personaclick.com/g' \ - -e 's/rees46/personaClick/g' \ - -e 's/REES46/PersonaClick/g' \ - -e 's/Rees46/PersonaClick/g' {} + + IFS=',' read -r -a replacement_extentions <<< "$REPLACMENT_EXTENTIONS" + IFS=',' read -r -a replacement_contents <<< "$REPLACEMENT_CONTENTS" + + find_conditions="" + for extention in "${replacement_extentions[@]}"; do + if [ -z "$find_conditions" ]; then + find_conditions="-name \"$extention\"" + else + find_conditions="$find_conditions -o -name \"$extention\"" + fi + done + + sed_arguments="" + for replacement_content in "${replacement_contents[@]}"; do + sed_arguments+="-e 's|$replacement_content|g' " + done + + eval "find . -type f \( $find_conditions \) -exec sed -i $sed_arguments" {} + - name: Get last merged PR author login working-directory: source From 2693e093fa12c127222fdfbdeefa23688c503076 Mon Sep 17 00:00:00 2001 From: kirill ivanov Date: Sun, 30 Mar 2025 21:38:33 +0300 Subject: [PATCH 03/22] refactor(github): uncomment debugs --- .github/workflows/synchronization.yaml | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/.github/workflows/synchronization.yaml b/.github/workflows/synchronization.yaml index 4795795e..a9a0b9f0 100644 --- a/.github/workflows/synchronization.yaml +++ b/.github/workflows/synchronization.yaml @@ -8,19 +8,16 @@ env: REPLACEMENT_CONTENTS: "https://api.rees46.com/|https://api.personaclick.com/,com.rees46:rees46-sdk|com.personaclick:personaclick-sdk,api.rees46.com|api.personaclick.com,rees46.com|personaclick.com,rees46|personaClick,REES46|PersonaClick,Rees46|PersonaClick" on: - # TODO uncomment pull_request: - # pull_request: - # types: - # - closed - # branches: - # - master - # workflow_dispatch: + types: + - closed + branches: + - master + workflow_dispatch: jobs: run: - # TODO uncomment - # if: github.event.pull_request.merged == true || github.event_name == 'workflow_dispatch' + if: github.event.pull_request.merged == true || github.event_name == 'workflow_dispatch' runs-on: ubuntu-latest steps: - name: Checkout From 42b918a5ae516185b5c37c68427c9d8f314eac22 Mon Sep 17 00:00:00 2001 From: kirill ivanov Date: Mon, 31 Mar 2025 14:16:33 +0300 Subject: [PATCH 04/22] feat(github): github pr action --- .../action.yml | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 .github/actions/github/create-pull-request-on-target-repo/action.yml diff --git a/.github/actions/github/create-pull-request-on-target-repo/action.yml b/.github/actions/github/create-pull-request-on-target-repo/action.yml new file mode 100644 index 00000000..42400d5c --- /dev/null +++ b/.github/actions/github/create-pull-request-on-target-repo/action.yml @@ -0,0 +1,78 @@ +name: Create pull request on target repo +description: Completed step to create pull request on target repo + +inputs: + sourceDirectory: + default: source + description: Commit author GitGup token + required: true + targetDirectory: + default: target + description: Commit author GitGup token + required: true + managerUsername: + description: PullRequest reviewer username + default: TorinAsakura + required: true + githubToken: + description: GitHup token + required: true + +runs: + using: composite + + steps: + - name: Get last merged PR author login + shell: bash + working-directory: ${{ inputs.sourceDirectory }} + id: pr_author + env: + GH_TOKEN: ${{ inputs.githubToken }} + run: | + PR_NUMBER=$(gh pr list --state merged --limit 1 --json number --jq '.[0].number') + LAST_PR_AUTHOR=$(gh pr view $PR_NUMBER --json author --jq '.author.login') + echo "LAST_PR_AUTHOR=$LAST_PR_AUTHOR" >> $GITHUB_OUTPUT + + - name: Create commit + shell: bash + working-directory: ${{ inputs.targetDirectory }} + env: + GITHUB_TOKEN: ${{ inputs.githubToken }} + run: | + git config --global user.name Jade Smith + git config --global user.email github-bot@rees46.com + git add . + echo "Changes to be committed:" + git diff --staged + git commit -m "feat: release" + + - name: Set branch name + shell: bash + id: branch_name + run: echo "BRANCH_NAME=feat/new-release-$(date +%Y%m%d%H%M%S)" >> $GITHUB_OUTPUT + + - name: Checkout new branch and push + shell: bash + working-directory: ${{ inputs.targetDirectory }} + env: + GITHUB_TOKEN: ${{ inputs.githubToken }} + BRANCH_NAME: ${{ steps.branch_name.outputs.BRANCH_NAME }} + run: | + git checkout -b $BRANCH_NAME + git push --set-upstream origin $BRANCH_NAME + + - name: Create Pull Request + shell: bash + working-directory: ${{ inputs.targetDirectory }} + env: + GITHUB_TOKEN: ${{ inputs.githubToken }} + BRANCH_NAME: ${{ steps.branch_name.outputs.BRANCH_NAME }} + LAST_PR_AUTHOR: ${{ steps.pr_author.outputs.LAST_PR_AUTHOR }} + MANAGER: ${{ inputs.managerUsername }} + run: | + PR_TITLE="Automated release" + PR_BODY="This is an automated pull request to update from branch $BRANCH_NAME" + DEFAULT_BRANCH=$(gh repo view --json defaultBranchRef -q ".defaultBranchRef.name") + echo "Assigning PR to LAST_PR_AUTHOR: $LAST_PR_AUTHOR" + echo "Adding MANAGER: $MANAGER as a reviewer" + gh pr create --title "$PR_TITLE" --body "$PR_BODY" --base "$DEFAULT_BRANCH" --head $BRANCH_NAME --assignee $LAST_PR_AUTHOR --reviewer $MANAGER From b41f35e563d0a3c9d812fff72fb81525b4212df5 Mon Sep 17 00:00:00 2001 From: kirill ivanov Date: Mon, 31 Mar 2025 14:19:20 +0300 Subject: [PATCH 05/22] feat(github): use commit app & bot creds feat(github): useless feat(github): useless feat(github): useless feat(github): useless feat(github): useless feat(github): useless feat(github): useless feat(github): useless feat(github): useless feat(github): useless feat(github): useless feat(github): useless feat(github): useless feat(github): useless feat(github): useless feat(github): useless feat(github): useless feat(github): useless feat(github): useless feat(github): useless feat(github): useless feat(github): useless feat(github): useless feat(github): useless feat(github): useless feat(github): useless feat(github): useless feat(github): useless feat(github): useless feat(github): useless feat(github): useless feat(github): useless feat(github): useless feat(github): useless feat(github): useless feat(github): useless feat(github): useless feat(github): useless feat(github): useless feat(github): useless feat(github): useless feat(github): useless feat(github): useless feat(github): useless feat(github): useless feat(github): useless feat(github): useless feat(github): useless feat(github): useless feat(github): useless feat(github): useless feat(github): useless feat(github): useless feat(github): useless feat(github): useless feat(github): useless feat(github): useless feat(github): useless feat(github): useless feat(github): useless feat(github): useless feat(github): useless feat(github): useless --- .../github/checkout/new-branch/action.yml | 27 ++++ .../actions/github/commit/create/action.yml | 26 ++++ .../action.yml | 78 ------------ .../github/pull-request/create/action.yml | 42 +++++++ .../pull-request/get-last-author/action.yml | 31 +++++ .github/actions/github/push/create/action.yml | 25 ++++ .../utils/get-new-branch-name/action.yml | 16 +++ .github/workflows/synchronization.yaml | 117 +++++++++--------- .gitignore | 1 + 9 files changed, 228 insertions(+), 135 deletions(-) create mode 100644 .github/actions/github/checkout/new-branch/action.yml create mode 100644 .github/actions/github/commit/create/action.yml delete mode 100644 .github/actions/github/create-pull-request-on-target-repo/action.yml create mode 100644 .github/actions/github/pull-request/create/action.yml create mode 100644 .github/actions/github/pull-request/get-last-author/action.yml create mode 100644 .github/actions/github/push/create/action.yml create mode 100644 .github/actions/github/utils/get-new-branch-name/action.yml diff --git a/.github/actions/github/checkout/new-branch/action.yml b/.github/actions/github/checkout/new-branch/action.yml new file mode 100644 index 00000000..f7a5abfd --- /dev/null +++ b/.github/actions/github/checkout/new-branch/action.yml @@ -0,0 +1,27 @@ +name: Checkout new branch +description: checkout new branch + +inputs: + targetDirectory: + description: working directory + default: tmp/target + required: true + branchName: + description: new branch name + required: true + +runs: + using: composite + + steps: + - name: Checkout new branch + shell: bash + working-directory: ${{ inputs.targetDirectory }} + run: | + git checkout -b ${{ inputs.branchName }} + + - name: Push new branch + shell: bash + working-directory: ${{ inputs.targetDirectory }} + run: | + git push --set-upstream origin ${{ inputs.branchName }} diff --git a/.github/actions/github/commit/create/action.yml b/.github/actions/github/commit/create/action.yml new file mode 100644 index 00000000..dd94ca6b --- /dev/null +++ b/.github/actions/github/commit/create/action.yml @@ -0,0 +1,26 @@ +name: Create commit +description: create commit + +inputs: + targetRepository: + description: Target repository to commit + required: true + githubToken: + description: GitHup token + required: true + branchName: + description: Branch to commit + required: true + +runs: + using: composite + + steps: + - name: Commit changes + uses: planetscale/ghcommit-action@v0.2.0 + env: + GITHUB_TOKEN: ${{ inputs.githubToken }} + with: + repo: ${{ inputs.targetRepository }} + branch: ${{ inputs.branchName }} + commit_message: "feat: release" diff --git a/.github/actions/github/create-pull-request-on-target-repo/action.yml b/.github/actions/github/create-pull-request-on-target-repo/action.yml deleted file mode 100644 index 42400d5c..00000000 --- a/.github/actions/github/create-pull-request-on-target-repo/action.yml +++ /dev/null @@ -1,78 +0,0 @@ -name: Create pull request on target repo -description: Completed step to create pull request on target repo - -inputs: - sourceDirectory: - default: source - description: Commit author GitGup token - required: true - targetDirectory: - default: target - description: Commit author GitGup token - required: true - managerUsername: - description: PullRequest reviewer username - default: TorinAsakura - required: true - githubToken: - description: GitHup token - required: true - -runs: - using: composite - - steps: - - name: Get last merged PR author login - shell: bash - working-directory: ${{ inputs.sourceDirectory }} - id: pr_author - env: - GH_TOKEN: ${{ inputs.githubToken }} - run: | - PR_NUMBER=$(gh pr list --state merged --limit 1 --json number --jq '.[0].number') - LAST_PR_AUTHOR=$(gh pr view $PR_NUMBER --json author --jq '.author.login') - echo "LAST_PR_AUTHOR=$LAST_PR_AUTHOR" >> $GITHUB_OUTPUT - - - name: Create commit - shell: bash - working-directory: ${{ inputs.targetDirectory }} - env: - GITHUB_TOKEN: ${{ inputs.githubToken }} - run: | - git config --global user.name Jade Smith - git config --global user.email github-bot@rees46.com - git add . - echo "Changes to be committed:" - git diff --staged - git commit -m "feat: release" - - - name: Set branch name - shell: bash - id: branch_name - run: echo "BRANCH_NAME=feat/new-release-$(date +%Y%m%d%H%M%S)" >> $GITHUB_OUTPUT - - - name: Checkout new branch and push - shell: bash - working-directory: ${{ inputs.targetDirectory }} - env: - GITHUB_TOKEN: ${{ inputs.githubToken }} - BRANCH_NAME: ${{ steps.branch_name.outputs.BRANCH_NAME }} - run: | - git checkout -b $BRANCH_NAME - git push --set-upstream origin $BRANCH_NAME - - - name: Create Pull Request - shell: bash - working-directory: ${{ inputs.targetDirectory }} - env: - GITHUB_TOKEN: ${{ inputs.githubToken }} - BRANCH_NAME: ${{ steps.branch_name.outputs.BRANCH_NAME }} - LAST_PR_AUTHOR: ${{ steps.pr_author.outputs.LAST_PR_AUTHOR }} - MANAGER: ${{ inputs.managerUsername }} - run: | - PR_TITLE="Automated release" - PR_BODY="This is an automated pull request to update from branch $BRANCH_NAME" - DEFAULT_BRANCH=$(gh repo view --json defaultBranchRef -q ".defaultBranchRef.name") - echo "Assigning PR to LAST_PR_AUTHOR: $LAST_PR_AUTHOR" - echo "Adding MANAGER: $MANAGER as a reviewer" - gh pr create --title "$PR_TITLE" --body "$PR_BODY" --base "$DEFAULT_BRANCH" --head $BRANCH_NAME --assignee $LAST_PR_AUTHOR --reviewer $MANAGER diff --git a/.github/actions/github/pull-request/create/action.yml b/.github/actions/github/pull-request/create/action.yml new file mode 100644 index 00000000..d3ae2699 --- /dev/null +++ b/.github/actions/github/pull-request/create/action.yml @@ -0,0 +1,42 @@ +name: Create pull request on target repo +description: create pull request on target repo + +inputs: + targetDirectory: + default: tmp/target + description: Commit author GitGup token + required: true + githubToken: + description: GitHup token + required: true + reviewerUsername: + description: PullRequest reviewer username + default: TorinAsakura + required: true + lastPrAuthor: + description: PullRequest reviewer username + default: TorinAsakura + required: true + branchName: + description: git branch name + required: true + +runs: + using: composite + + steps: + - name: Create Pull Request + shell: bash + working-directory: ${{ inputs.targetDirectory }} + env: + GITHUB_TOKEN: ${{ inputs.githubToken }} + BRANCH_NAME: ${{ inputs.branchName }} + LAST_PR_AUTHOR: ${{ inputs.lastPrAuthor }} + REVIEWER: ${{ inputs.reviewerUsername }} + run: | + PR_TITLE="Automated release" + PR_BODY="This is an automated pull request to update from branch $BRANCH_NAME" + DEFAULT_BRANCH=$(gh repo view --json defaultBranchRef -q ".defaultBranchRef.name") + echo "Assigning PR to LAST_PR_AUTHOR: $LAST_PR_AUTHOR" + echo "Adding REVIEWER: $REVIEWER as a reviewer" + gh pr create --title "$PR_TITLE" --body "$PR_BODY" --base "$DEFAULT_BRANCH" --head $BRANCH_NAME --assignee $LAST_PR_AUTHOR --reviewer $REVIEWER diff --git a/.github/actions/github/pull-request/get-last-author/action.yml b/.github/actions/github/pull-request/get-last-author/action.yml new file mode 100644 index 00000000..98c28ed8 --- /dev/null +++ b/.github/actions/github/pull-request/get-last-author/action.yml @@ -0,0 +1,31 @@ +name: Get last merget PullRequest author +description: get last merget pull request author + +inputs: + sourceDirectory: + default: tmp/source + description: Commit author GitGup token + required: true + githubToken: + description: GitHup token + required: true + +outputs: + lastPrAuthor: + description: Get branch name + value: ${{ steps.pr_author.outputs.lastPrAuthor }} + +runs: + using: composite + + steps: + - name: Get last merged PR author login + shell: bash + working-directory: ${{ inputs.sourceDirectory }} + id: pr_author + env: + GH_TOKEN: ${{ inputs.githubToken }} + run: | + PR_NUMBER=$(gh pr list --state merged --limit 1 --json number --jq '.[0].number') + LAST_PR_AUTHOR=$(gh pr view $PR_NUMBER --json author --jq '.author.login') + echo "lastPrAuthor=$LAST_PR_AUTHOR" >> $GITHUB_OUTPUT diff --git a/.github/actions/github/push/create/action.yml b/.github/actions/github/push/create/action.yml new file mode 100644 index 00000000..0b83944f --- /dev/null +++ b/.github/actions/github/push/create/action.yml @@ -0,0 +1,25 @@ +name: Git push +description: gith push + +inputs: + targetDirectory: + default: tmp/target + description: TargetDirectory + required: true + githubToken: + description: GitHup token + required: true + branchName: + description: branchName + required: true + +runs: + using: composite + + steps: + - shell: bash + working-directory: ${{ inputs.targetDirectory }} + env: + GITHUB_TOKEN: ${{ inputs.githubToken }} + run: | + git push --set-upstream origin ${{ inputs.branchName }} diff --git a/.github/actions/github/utils/get-new-branch-name/action.yml b/.github/actions/github/utils/get-new-branch-name/action.yml new file mode 100644 index 00000000..a090f32c --- /dev/null +++ b/.github/actions/github/utils/get-new-branch-name/action.yml @@ -0,0 +1,16 @@ +name: Get new branch name +description: get new branch name with now date + +outputs: + branchName: + description: Get last merged PR author + value: ${{ steps.branch_name.outputs.branchName }} + +runs: + using: composite + + steps: + - name: Get new branch name + shell: bash + id: branch_name + run: echo "branchName=feat/new-release-$(date +%Y%m%d%H%M%S)" >> $GITHUB_OUTPUT diff --git a/.github/workflows/synchronization.yaml b/.github/workflows/synchronization.yaml index a9a0b9f0..02e7a9c8 100644 --- a/.github/workflows/synchronization.yaml +++ b/.github/workflows/synchronization.yaml @@ -1,41 +1,50 @@ name: PersonaClick Synchronization env: - TERGET_REPO: "PersonaClick/workflow" - MANAGER_USERNAME: TorinAsakura - SYNC_IGNORE: ".git,.idea,.gitignore,LICENSE,.github/workflows/synchronization.yaml" + TARGET_REPO: "PersonaClick/workflow" + SYNC_IGNORE: ".git,.idea,LICENSE,.github/workflows/synchronization.yaml" REPLACMENT_EXTENTIONS: "*.ts,*.sh,*.yaml" REPLACEMENT_CONTENTS: "https://api.rees46.com/|https://api.personaclick.com/,com.rees46:rees46-sdk|com.personaclick:personaclick-sdk,api.rees46.com|api.personaclick.com,rees46.com|personaclick.com,rees46|personaClick,REES46|PersonaClick,Rees46|PersonaClick" on: pull_request: - types: - - closed - branches: - - master - workflow_dispatch: + # TODO uncomment + # pull_request: + # types: + # - closed + # branches: + # - master + # workflow_dispatch: jobs: run: - if: github.event.pull_request.merged == true || github.event_name == 'workflow_dispatch' + # TODO uncomment + # if: github.event.pull_request.merged == true || github.event_name == 'workflow_dispatch' runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 with: - path: source + path: tmp/source env: GITHUB_TOKEN: ${{ secrets.JADE_SMITH_BOT_TOKEN }} - name: Check out remote repository uses: actions/checkout@v4 with: - repository: ${{ env.TERGET_REPO }} + repository: ${{ env.TARGET_REPO }} token: ${{ secrets.JADE_SMITH_BOT_TOKEN }} - path: target + path: tmp/target + + - uses: actions/create-github-app-token@v1 + id: appTokenStep + with: + app-id: ${{ vars.PERSONACLICK_COURIER_ID }} + private-key: ${{ secrets.PERSONACLICK_COURIER_SECRET }} + owner: PersonaClick - name: Clean target directory except excluded files - working-directory: target + working-directory: tmp/target run: | IFS=',' read -r -a ignored_files <<< "$SYNC_IGNORE" @@ -58,10 +67,10 @@ jobs: echo $exclude_conditions - eval rsync -av --progress source/ target/ $exclude_conditions + eval rsync -av --progress tmp/source/ tmp/target/ $exclude_conditions - name: Apply changes to files - working-directory: target + working-directory: tmp/target run: | IFS=',' read -r -a replacement_extentions <<< "$REPLACMENT_EXTENTIONS" IFS=',' read -r -a replacement_contents <<< "$REPLACEMENT_CONTENTS" @@ -82,52 +91,46 @@ jobs: eval "find . -type f \( $find_conditions \) -exec sed -i $sed_arguments" {} + - - name: Get last merged PR author login - working-directory: source - id: pr_author + - name: Copy files from targe dir run: | - PR_NUMBER=$(gh pr list --state merged --limit 1 --json number --jq '.[0].number') - LAST_PR_AUTHOR=$(gh pr view $PR_NUMBER --json author --jq '.author.login') - echo "LAST_PR_AUTHOR=$LAST_PR_AUTHOR" >> $GITHUB_OUTPUT - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + rsync -a tmp/target/ . - - name: Create commit - working-directory: target + - name: Debug current dir run: | - git config --global user.name Jade Smith - git config --global user.email github-bot@rees46.com git add . - echo "Changes to be committed:" - git diff --staged - git commit -m "feat: release" - env: - GITHUB_TOKEN: ${{ secrets.JADE_SMITH_BOT_TOKEN }} - - name: Set branch name - id: branch_name - run: echo "BRANCH_NAME=feat/new-release-$(date +%Y%m%d%H%M%S)" >> $GITHUB_OUTPUT + # TODO uncomment + # - uses: rees46/workflow/.github/actions/github/get-last-pr-author@master + - uses: rees46/workflow/.github/actions/github/pull-request/get-last-author@feat/sync + id: lastPrAuthorStep + with: + githubToken: ${{ steps.appTokenStep.outputs.token }} - - name: Checkout new branch and push - working-directory: target - run: | - git checkout -b $BRANCH_NAME - git push --set-upstream origin $BRANCH_NAME - env: - GITHUB_TOKEN: ${{ secrets.JADE_SMITH_BOT_TOKEN }} - BRANCH_NAME: ${{ steps.branch_name.outputs.BRANCH_NAME }} + # TODO master branch + - uses: rees46/workflow/.github/actions/github/utils/get-new-branch-name@feat/sync + id: newBranchNameStep - - name: Create Pull Request - working-directory: target - run: | - PR_TITLE="Automated release" - PR_BODY="This is an automated pull request to update from branch $BRANCH_NAME" - DEFAULT_BRANCH=$(gh repo view --json defaultBranchRef -q ".defaultBranchRef.name") - echo "Assigning PR to LAST_PR_AUTHOR: $LAST_PR_AUTHOR" - echo "Adding MANAGER: $MANAGER as a reviewer" - gh pr create --title "$PR_TITLE" --body "$PR_BODY" --base "$DEFAULT_BRANCH" --head $BRANCH_NAME --assignee $LAST_PR_AUTHOR --reviewer $MANAGER - env: - GITHUB_TOKEN: ${{ secrets.JADE_SMITH_BOT_TOKEN }} - BRANCH_NAME: ${{ steps.branch_name.outputs.BRANCH_NAME }} - LAST_PR_AUTHOR: ${{ steps.pr_author.outputs.LAST_PR_AUTHOR }} - MANAGER: ${{ env.MANAGER_USERNAME }} + # TODO master branch + - uses: rees46/workflow/.github/actions/github/checkout/new-branch@feat/sync + with: + branchName: ${{ steps.newBranchNameStep.outputs.branchName }} + + # TODO master branch + - uses: rees46/workflow/.github/actions/github/push/create@feat/sync + with: + branchName: ${{ steps.newBranchNameStep.outputs.branchName }} + githubToken: ${{ steps.appTokenStep.outputs.token }} + + # TODO master branch + - uses: rees46/workflow/.github/actions/github/commit/create@feat/sync + with: + branchName: ${{ steps.newBranchNameStep.outputs.branchName }} + githubToken: ${{ steps.appTokenStep.outputs.token }} + targetRepository: ${{ env.TARGET_REPO }} + + # TODO master branch + - uses: rees46/workflow/.github/actions/github/pull-request/create@feat/sync + with: + githubToken: ${{ steps.appTokenStep.outputs.token }} + lastPrAuthor: ${{ steps.lastPrAuthorStep.outputs.lastPrAuthor }} + branchName: ${{ steps.newBranchNameStep.outputs.branchName }} diff --git a/.gitignore b/.gitignore index 69880ddc..aeab77ca 100644 --- a/.gitignore +++ b/.gitignore @@ -50,3 +50,4 @@ dist # Env .env +tmp/ From b529e6c152e84969072253acdf0e0b07bf2f0c7f Mon Sep 17 00:00:00 2001 From: kirill ivanov Date: Tue, 1 Apr 2025 00:03:49 +0300 Subject: [PATCH 06/22] style(github): format --- .github/actions/github/commit/create/action.yml | 2 +- .github/workflows/synchronization.yaml | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/actions/github/commit/create/action.yml b/.github/actions/github/commit/create/action.yml index dd94ca6b..8dd0d394 100644 --- a/.github/actions/github/commit/create/action.yml +++ b/.github/actions/github/commit/create/action.yml @@ -23,4 +23,4 @@ runs: with: repo: ${{ inputs.targetRepository }} branch: ${{ inputs.branchName }} - commit_message: "feat: release" + commit_message: 'feat: release' diff --git a/.github/workflows/synchronization.yaml b/.github/workflows/synchronization.yaml index 02e7a9c8..36019cf0 100644 --- a/.github/workflows/synchronization.yaml +++ b/.github/workflows/synchronization.yaml @@ -1,10 +1,10 @@ name: PersonaClick Synchronization env: - TARGET_REPO: "PersonaClick/workflow" - SYNC_IGNORE: ".git,.idea,LICENSE,.github/workflows/synchronization.yaml" - REPLACMENT_EXTENTIONS: "*.ts,*.sh,*.yaml" - REPLACEMENT_CONTENTS: "https://api.rees46.com/|https://api.personaclick.com/,com.rees46:rees46-sdk|com.personaclick:personaclick-sdk,api.rees46.com|api.personaclick.com,rees46.com|personaclick.com,rees46|personaClick,REES46|PersonaClick,Rees46|PersonaClick" + TARGET_REPO: 'PersonaClick/workflow' + SYNC_IGNORE: '.git,.idea,LICENSE,.github/workflows/synchronization.yaml' + REPLACMENT_EXTENTIONS: '*.ts,*.sh,*.yaml' + REPLACEMENT_CONTENTS: 'https://api.rees46.com/|https://api.personaclick.com/,com.rees46:rees46-sdk|com.personaclick:personaclick-sdk,api.rees46.com|api.personaclick.com,rees46.com|personaclick.com,rees46|personaClick,REES46|PersonaClick,Rees46|PersonaClick' on: pull_request: From fc0a69a0e8eb2f11e337aa10088123aa75791700 Mon Sep 17 00:00:00 2001 From: kirill ivanov Date: Tue, 1 Apr 2025 00:06:38 +0300 Subject: [PATCH 07/22] chore(github): remove debugs --- .github/workflows/synchronization.yaml | 42 ++++++++++---------------- 1 file changed, 16 insertions(+), 26 deletions(-) diff --git a/.github/workflows/synchronization.yaml b/.github/workflows/synchronization.yaml index 36019cf0..33713792 100644 --- a/.github/workflows/synchronization.yaml +++ b/.github/workflows/synchronization.yaml @@ -1,25 +1,22 @@ name: PersonaClick Synchronization env: - TARGET_REPO: 'PersonaClick/workflow' - SYNC_IGNORE: '.git,.idea,LICENSE,.github/workflows/synchronization.yaml' - REPLACMENT_EXTENTIONS: '*.ts,*.sh,*.yaml' - REPLACEMENT_CONTENTS: 'https://api.rees46.com/|https://api.personaclick.com/,com.rees46:rees46-sdk|com.personaclick:personaclick-sdk,api.rees46.com|api.personaclick.com,rees46.com|personaclick.com,rees46|personaClick,REES46|PersonaClick,Rees46|PersonaClick' + TARGET_REPO: "PersonaClick/workflow" + SYNC_IGNORE: ".git,.idea,LICENSE,.github/workflows/synchronization.yaml" + REPLACMENT_EXTENTIONS: "*.ts,*.sh,*.yaml" + REPLACEMENT_CONTENTS: "https://api.rees46.com/|https://api.personaclick.com/,com.rees46:rees46-sdk|com.personaclick:personaclick-sdk,api.rees46.com|api.personaclick.com,rees46.com|personaclick.com,rees46|personaClick,REES46|PersonaClick,Rees46|PersonaClick" on: pull_request: - # TODO uncomment - # pull_request: - # types: - # - closed - # branches: - # - master - # workflow_dispatch: + types: + - closed + branches: + - master + workflow_dispatch: jobs: run: - # TODO uncomment - # if: github.event.pull_request.merged == true || github.event_name == 'workflow_dispatch' + if: github.event.pull_request.merged == true || github.event_name == 'workflow_dispatch' runs-on: ubuntu-latest steps: - name: Checkout @@ -99,37 +96,30 @@ jobs: run: | git add . - # TODO uncomment - # - uses: rees46/workflow/.github/actions/github/get-last-pr-author@master - - uses: rees46/workflow/.github/actions/github/pull-request/get-last-author@feat/sync + - uses: rees46/workflow/.github/actions/github/pull-request/get-last-author@master id: lastPrAuthorStep with: githubToken: ${{ steps.appTokenStep.outputs.token }} - # TODO master branch - - uses: rees46/workflow/.github/actions/github/utils/get-new-branch-name@feat/sync + - uses: rees46/workflow/.github/actions/github/utils/get-new-branch-name@master id: newBranchNameStep - # TODO master branch - - uses: rees46/workflow/.github/actions/github/checkout/new-branch@feat/sync + - uses: rees46/workflow/.github/actions/github/checkout/new-branch@master with: branchName: ${{ steps.newBranchNameStep.outputs.branchName }} - # TODO master branch - - uses: rees46/workflow/.github/actions/github/push/create@feat/sync + - uses: rees46/workflow/.github/actions/github/push/create@master with: branchName: ${{ steps.newBranchNameStep.outputs.branchName }} githubToken: ${{ steps.appTokenStep.outputs.token }} - # TODO master branch - - uses: rees46/workflow/.github/actions/github/commit/create@feat/sync + - uses: rees46/workflow/.github/actions/github/commit/create@master with: branchName: ${{ steps.newBranchNameStep.outputs.branchName }} githubToken: ${{ steps.appTokenStep.outputs.token }} targetRepository: ${{ env.TARGET_REPO }} - # TODO master branch - - uses: rees46/workflow/.github/actions/github/pull-request/create@feat/sync + - uses: rees46/workflow/.github/actions/github/pull-request/create@master with: githubToken: ${{ steps.appTokenStep.outputs.token }} lastPrAuthor: ${{ steps.lastPrAuthorStep.outputs.lastPrAuthor }} From 2bcc50f20afc1eda3f089e794230249ded395946 Mon Sep 17 00:00:00 2001 From: kirill ivanov Date: Wed, 2 Apr 2025 11:23:06 +0300 Subject: [PATCH 08/22] style(github): order, namings --- .../reusable-android-synchronization.yaml | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/reusable-android-synchronization.yaml b/.github/workflows/reusable-android-synchronization.yaml index e31ab271..21e981a7 100644 --- a/.github/workflows/reusable-android-synchronization.yaml +++ b/.github/workflows/reusable-android-synchronization.yaml @@ -1,14 +1,14 @@ -name: Sync iOS Repositories +name: Sync Android Repositories on: workflow_call: - secrets: - token: - required: true inputs: targetRepository: type: string required: true + secrets: + token: + required: true jobs: run: @@ -22,10 +22,17 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.token }} + - name: Checkout remote repository + uses: actions/checkout@v4 + with: + repository: ${{inputs.targetRepository}} + token: ${{ secrets.token }} + path: target + - name: Get current version from source working-directory: source env: - FILE_PATH: 'version.properties' + FILE_PATH: "version.properties" id: version_source run: | current_version=$(awk -F"=" '/VERSION_NAME/ {print $2}' "$FILE_PATH") @@ -41,13 +48,6 @@ jobs: env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Check out remote repository - uses: actions/checkout@v4 - with: - repository: ${{inputs.targetRepository}} - token: ${{ secrets.token }} - path: target - - name: Clean target directory except excluded files run: | rsync -av --delete --exclude-from=<(echo \ From 73972cf42a92fc74231b39cd8512adb4cd00b34d Mon Sep 17 00:00:00 2001 From: kirill ivanov Date: Wed, 2 Apr 2025 12:13:28 +0300 Subject: [PATCH 09/22] refactor(github): reuse action on repo, workflow-wide-constants --- .../reusable-android-synchronization.yaml | 226 ++++++++++-------- 1 file changed, 124 insertions(+), 102 deletions(-) diff --git a/.github/workflows/reusable-android-synchronization.yaml b/.github/workflows/reusable-android-synchronization.yaml index 21e981a7..33b156b2 100644 --- a/.github/workflows/reusable-android-synchronization.yaml +++ b/.github/workflows/reusable-android-synchronization.yaml @@ -1,13 +1,41 @@ name: Sync Android Repositories +env: + TARGET_TMP_DIR_PATH: tmp/target + SOURCE_TMP_DIR_PATH: tmp/source + on: workflow_call: inputs: + appId: + type: string + required: true targetRepository: type: string required: true + sourceDirname: + type: string + required: true + targetDirname: + type: string + required: true + syncIgnore: + type: string + required: true + description: list of files to exclue, separated by ',' + default: ".git,.idea,LICENSE," + replacementExtentions: + type: string + required: true + description: list of extentions to replace, separated by ',' + default: "*.ts,*.sh,*.yaml" + replacementContents: + type: string + required: true + description: list of contents to replace, separated by ',' and '|' - separate source target content\ + default: "source:content:1|target:conten:1,source-content-1|target-content-1" secrets: - token: + privateKey: required: true jobs: @@ -15,93 +43,92 @@ jobs: name: Synchronization runs-on: ubuntu-latest steps: + - uses: actions/create-github-app-token@v1 + id: appTokenStep + with: + app-id: ${{ vars.PERSONACLICK_COURIER_ID }} + private-key: ${{ secrets.PERSONACLICK_COURIER_SECRET }} + # TODO if need - provide it + # owner: PersonaClick + - name: Checkout uses: actions/checkout@v4 with: - path: source - env: - GITHUB_TOKEN: ${{ secrets.token }} + path: ${{ env.SOURCE_TMP_DIR_PATH }} + token: ${{ steps.appTokenStep.outputs.token }} - name: Checkout remote repository uses: actions/checkout@v4 with: + path: ${{ env.TARGET_TMP_DIR_PATH }} + token: ${{ steps.appTokenStep.outputs.token }} repository: ${{inputs.targetRepository}} - token: ${{ secrets.token }} - path: target - - name: Get current version from source - working-directory: source + # TODO move to actions + - name: Clean target directory except excluded files + working-directory: ${{ env.TARGET_TMP_DIR_PATH }} env: - FILE_PATH: "version.properties" - id: version_source + SYNC_IGNORE: ${{ inputs.syncIgnore }} run: | - current_version=$(awk -F"=" '/VERSION_NAME/ {print $2}' "$FILE_PATH") - echo "version=$current_version" >> $GITHUB_OUTPUT + IFS=',' read -r -a ignored_files <<< "$SYNC_IGNORE" - - name: Get last merged PR author login - working-directory: source - id: pr_author - run: | - PR_NUMBER=$(gh pr list --state merged --limit 1 --json number --jq '.[0].number') - LAST_PR_AUTHOR=$(gh pr view $PR_NUMBER --json author --jq '.author.login') - echo "LAST_PR_AUTHOR=$LAST_PR_AUTHOR" >> $GITHUB_OUTPUT - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + exclude_conditions="" + for ignored_file in "${ignored_files[@]}"; do + exclude_conditions=" $exclude_conditions ! -name \"$ignored_file\"" + done - - name: Clean target directory except excluded files - run: | - rsync -av --delete --exclude-from=<(echo \ - '.git' \ - '.idea' \ - '.github' \ - '.gitignore' \ - 'LICENSE' \ - 'README.md' \ - 'version.properties' \ - ) /dev/null target/ + eval find . -mindepth 1 -maxdepth 1 $exclude_conditions -exec rm -rf {} + + # TODO move to actions + # TODO need to separete .github/workflows/synchronization.yaml into personal directory - name: Sync files to remote repository + env: + SYNC_IGNORE: ${{ inputs.syncIgnore }} run: | - rsync -av --progress \ - source/ target/ \ - --exclude '.git' \ - --exclude '.idea' \ - --exclude '.github' \ - --exclude '.gitignore' \ - --exclude 'LICENSE' \ - --exclude 'README.md' \ - --exclude 'version.properties' \ - - - name: Apply changes to Kotlin files - working-directory: target - run: | - find . -type f \( -name '*.kts' -o -name '*.kt' \) -exec sed -i \ - -e 's|https://api.rees46.com/|https://api.personaclick.com/|g' \ - -e 's/com.rees46:rees46-sdk/com.personaclick:personaclick-sdk/g' \ - -e 's/api.rees46.com/api.personaclick.com/g' \ - -e 's/rees46.com/personaclick.com/g' \ - -e 's/rees46/personaClick/g' \ - -e 's/REES46/PersonaClick/g' \ - -e 's/Rees46/PersonaClick/g' {} + - - - name: Apply changes to MD & XML & TOML files - working-directory: target + IFS=',' read -r -a ignored_files <<< "$SYNC_IGNORE" + + exclude_conditions="" + for ignored_file in "${ignored_files[@]}"; do + exclude_conditions=" $exclude_conditions --exclude \"$ignored_file\"" + done + + echo $exclude_conditions + + eval rsync -av --progress "$SOURCE_TMP_DIR_PATH" "$TARGET_TMP_DIR_PATH" $exclude_conditions + + # TODO move to actions + - name: Apply changes to files + working-directory: ${{ env.TARGET_TMP_DIR_PATH }} + env: + REPLACMENT_EXTENTIONS: ${{ inputs.replacementExtentions }} + REPLACEMENT_CONTENTS: ${{ inputs.replacementContents }} run: | - find . -type f \( -name '*.md' -o -name '*.xml' -o -name '*.toml' \) -exec sed -i \ - -e 's|https://api.rees46.com/|https://api.personaclick.com/|g' \ - -e 's/com.rees46:rees46-sdk/com.personaclick:personaclick-sdk/g' \ - -e 's/api.rees46.com/api.personaclick.com/g' \ - -e 's/rees46.com/personaclick.com/g' \ - -e 's/rees46/personaClick/g' \ - -e 's/REES46/PersonaClick/g' \ - -e 's/Rees46/PersonaClick/g' {} + + IFS=',' read -r -a replacement_extentions <<< "$REPLACMENT_EXTENTIONS" + IFS=',' read -r -a replacement_contents <<< "$REPLACEMENT_CONTENTS" + find_conditions="" + for extention in "${replacement_extentions[@]}"; do + if [ -z "$find_conditions" ]; then + find_conditions="-name \"$extention\"" + else + find_conditions="$find_conditions -o -name \"$extention\"" + fi + done + + sed_arguments="" + for replacement_content in "${replacement_contents[@]}"; do + sed_arguments+="-e 's|$replacement_content|g' " + done + + eval "find . -type f \( $find_conditions \) -exec sed -i $sed_arguments" {} + + + # TODO move to actions - name: Rename directories - working-directory: target + working-directory: ${{ TARGET_TMP_DIR_PATH }} run: | - find . -depth -type d -iname '*rees46*' -exec bash -c ' + find . -depth -type d -iname '*${{ inputs.sourceDirname }}*' -exec bash -c ' for dir; do - newdir=$(echo "$dir" | sed -e "s/rees46/personaClick/gi") + newdir=$(echo "$dir" | sed -e "s/${{ inputs.sourceDirname }}/${{ inputs.targetDirname }}/gi") if [ "$dir" != "$newdir" ]; then echo "Renaming directory: $dir -> $newdir" mv "$dir" "$newdir" @@ -109,42 +136,37 @@ jobs: done ' bash {} + - - name: Create commit - working-directory: target + # TODO move to actions + # TODO why not delete tmp? + - name: Copy files from targe dir run: | - git config --global user.name Jade Smith - git config --global user.email github-bot@rees46.com - git add . - echo "Changes to be committed:" - git diff --staged - git commit -m "feat: release" - env: - GITHUB_TOKEN: ${{ secrets.token }} + rsync -a "$TARGET_TMP_DIR_PATH" . + + - uses: rees46/workflow/.github/actions/github/pull-request/get-last-author@master + id: lastPrAuthorStep + with: + githubToken: ${{ steps.appTokenStep.outputs.token }} - - name: Set branch name - id: branch_name - run: echo "BRANCH_NAME=feat/new-release-$(date +%Y%m%d%H%M%S)" >> $GITHUB_OUTPUT + - uses: rees46/workflow/.github/actions/github/utils/get-new-branch-name@master + id: newBranchNameStep - - name: Checkout new branch and push - working-directory: target - run: | - git checkout -b $BRANCH_NAME - git push --set-upstream origin $BRANCH_NAME - env: - GITHUB_TOKEN: ${{ secrets.token }} - BRANCH_NAME: ${{ steps.branch_name.outputs.BRANCH_NAME }} + - uses: rees46/workflow/.github/actions/github/checkout/new-branch@master + with: + branchName: ${{ steps.newBranchNameStep.outputs.branchName }} - - name: Create Pull Request - working-directory: target - run: | - PR_TITLE="Automated release" - PR_BODY="This is an automated pull request to update from branch $BRANCH_NAME" - DEFAULT_BRANCH=$(gh repo view --json defaultBranchRef -q ".defaultBranchRef.name") - echo "Assigning PR to LAST_PR_AUTHOR: $LAST_PR_AUTHOR" - echo "Adding MANAGER: $MANAGER as a reviewer" - gh pr create --title "$PR_TITLE" --body "$PR_BODY" --base "$DEFAULT_BRANCH" --head $BRANCH_NAME --assignee $LAST_PR_AUTHOR --reviewer $MANAGER - env: - GITHUB_TOKEN: ${{ secrets.token }} - BRANCH_NAME: ${{ steps.branch_name.outputs.BRANCH_NAME }} - LAST_PR_AUTHOR: ${{ steps.pr_author.outputs.LAST_PR_AUTHOR }} - MANAGER: TorinAsakura + - uses: rees46/workflow/.github/actions/github/push/create@master + with: + branchName: ${{ steps.newBranchNameStep.outputs.branchName }} + githubToken: ${{ steps.appTokenStep.outputs.token }} + + - uses: rees46/workflow/.github/actions/github/commit/create@master + with: + branchName: ${{ steps.newBranchNameStep.outputs.branchName }} + githubToken: ${{ steps.appTokenStep.outputs.token }} + targetRepository: ${{ env.TARGET_REPO }} + + - uses: rees46/workflow/.github/actions/github/pull-request/create@master + with: + githubToken: ${{ steps.appTokenStep.outputs.token }} + lastPrAuthor: ${{ steps.lastPrAuthorStep.outputs.lastPrAuthor }} + branchName: ${{ steps.newBranchNameStep.outputs.branchName }} From 6d7841aa9607e576184f4218714b1e90c4835738 Mon Sep 17 00:00:00 2001 From: kirill ivanov Date: Wed, 2 Apr 2025 13:01:34 +0300 Subject: [PATCH 10/22] refactor(github): split into actions --- .github/actions/utils/fs/clean-dir/action.yml | 31 ++++++ .../actions/utils/fs/rename-dirs/action.yml | 32 ++++++ .../utils/fs/replace-file-content/action.yml | 50 +++++++++ .github/actions/utils/fs/sync-dirs/action.yml | 43 ++++++++ .../reusable-android-synchronization.yaml | 104 +++++------------- 5 files changed, 184 insertions(+), 76 deletions(-) create mode 100644 .github/actions/utils/fs/clean-dir/action.yml create mode 100644 .github/actions/utils/fs/rename-dirs/action.yml create mode 100644 .github/actions/utils/fs/replace-file-content/action.yml create mode 100644 .github/actions/utils/fs/sync-dirs/action.yml diff --git a/.github/actions/utils/fs/clean-dir/action.yml b/.github/actions/utils/fs/clean-dir/action.yml new file mode 100644 index 00000000..650e8802 --- /dev/null +++ b/.github/actions/utils/fs/clean-dir/action.yml @@ -0,0 +1,31 @@ +name: Clean directory +description: clean directory with excludes + +inputs: + targetDirectory: + description: working directory + default: tmp/target + required: true + syncIgnore: + description: working directory + default: tmp/target + required: true + +runs: + using: composite + + steps: + - name: Clean target directory except excluded files + shell: bash + working-directory: ${{ inputs.targetDirectory }} + env: + SYNC_IGNORE: ${{ inputs.syncIgnore }} + run: | + IFS=',' read -r -a ignored_files <<< "$SYNC_IGNORE" + + exclude_conditions="" + for ignored_file in "${ignored_files[@]}"; do + exclude_conditions=" $exclude_conditions ! -name \"$ignored_file\"" + done + + eval find . -mindepth 1 -maxdepth 1 $exclude_conditions -exec rm -rf {} + diff --git a/.github/actions/utils/fs/rename-dirs/action.yml b/.github/actions/utils/fs/rename-dirs/action.yml new file mode 100644 index 00000000..490a846d --- /dev/null +++ b/.github/actions/utils/fs/rename-dirs/action.yml @@ -0,0 +1,32 @@ +name: Rename directories +description: rename directories + +inputs: + targetDirectory: + description: working directory + default: tmp/target + required: true + sourceDirname: + description: dirname to rename + required: true + targetDirname: + description: name to rename + required: true + +runs: + using: composite + + steps: + - name: Rename directories + shell: bash + working-directory: ${{ inputs.targetDirectory }} + run: | + find . -depth -type d -iname '*${{ inputs.sourceDirname }}*' -exec bash -c ' + for dir; do + newdir=$(echo "$dir" | sed -e "s/${{ inputs.sourceDirname }}/${{ inputs.targetDirname }}/gi") + if [ "$dir" != "$newdir" ]; then + echo "Renaming directory: $dir -> $newdir" + mv "$dir" "$newdir" + fi + done + ' bash {} + diff --git a/.github/actions/utils/fs/replace-file-content/action.yml b/.github/actions/utils/fs/replace-file-content/action.yml new file mode 100644 index 00000000..9634ff98 --- /dev/null +++ b/.github/actions/utils/fs/replace-file-content/action.yml @@ -0,0 +1,50 @@ +name: Replace file content +description: replace file content + +inputs: + targetDirectory: + description: working directory + default: tmp/target + required: true + syncIgnore: + description: working directory + default: tmp/target + required: true + replacementExtentions: + required: true + description: list of extentions to replace, separated by ',' + default: "*.ts,*.sh,*.yaml" + replacementContents: + required: true + description: list of contents to replace, separated by ',' and '|' - separate source target content\ + default: "source:content:1|target:conten:1,source-content-1|target-content-1" + +runs: + using: composite + + steps: + - name: Replace file content + shell: bash + working-directory: ${{ inputs.targetDirectory }} + env: + REPLACMENT_EXTENTIONS: ${{ inputs.replacementExtentions }} + REPLACEMENT_CONTENTS: ${{ inputs.replacementContents }} + run: | + IFS=',' read -r -a replacement_extentions <<< "$REPLACMENT_EXTENTIONS" + IFS=',' read -r -a replacement_contents <<< "$REPLACEMENT_CONTENTS" + + find_conditions="" + for extention in "${replacement_extentions[@]}"; do + if [ -z "$find_conditions" ]; then + find_conditions="-name \"$extention\"" + else + find_conditions="$find_conditions -o -name \"$extention\"" + fi + done + + sed_arguments="" + for replacement_content in "${replacement_contents[@]}"; do + sed_arguments+="-e 's|$replacement_content|g' " + done + + eval "find . -type f \( $find_conditions \) -exec sed -i $sed_arguments" {} + diff --git a/.github/actions/utils/fs/sync-dirs/action.yml b/.github/actions/utils/fs/sync-dirs/action.yml new file mode 100644 index 00000000..b434e954 --- /dev/null +++ b/.github/actions/utils/fs/sync-dirs/action.yml @@ -0,0 +1,43 @@ +name: Sync directories +description: synchronization directories with excludes + +inputs: + sourceDirectory: + description: working directory + default: tmp/source + required: true + targetDirectory: + description: working directory + default: tmp/target + required: true + syncIgnore: + description: working directory + +runs: + using: composite + + steps: + - name: Sync files to remote repository + if: ${{ inputs.syncIgnore != '' }} + shell: bash + env: + SYNC_IGNORE: ${{ inputs.syncIgnore }} + SOURCE_TMP_DIR_PATH: ${{ inputs.sourceDirectory }} + TARGET_TMP_DIR_PATH: ${{ inputs.targetDirectory }} + run: | + IFS=',' read -r -a ignored_files <<< "$SYNC_IGNORE" + + exclude_conditions="" + for ignored_file in "${ignored_files[@]}"; do + exclude_conditions=" $exclude_conditions --exclude \"$ignored_file\"" + done + + echo $exclude_conditions + + eval rsync -av --progress "$SOURCE_TMP_DIR_PATH" "$TARGET_TMP_DIR_PATH" $exclude_conditions + + - name: Sync files to remote repository + if: ${{ inputs.syncIgnore == '' }} + shell: bash + run: | + rsync -a "${{ inputs.targetDirectory }}" "${{ inputs.sourceDirectory }}" diff --git a/.github/workflows/reusable-android-synchronization.yaml b/.github/workflows/reusable-android-synchronization.yaml index 33b156b2..f36339ee 100644 --- a/.github/workflows/reusable-android-synchronization.yaml +++ b/.github/workflows/reusable-android-synchronization.yaml @@ -64,83 +64,35 @@ jobs: token: ${{ steps.appTokenStep.outputs.token }} repository: ${{inputs.targetRepository}} - # TODO move to actions - - name: Clean target directory except excluded files - working-directory: ${{ env.TARGET_TMP_DIR_PATH }} - env: - SYNC_IGNORE: ${{ inputs.syncIgnore }} - run: | - IFS=',' read -r -a ignored_files <<< "$SYNC_IGNORE" - - exclude_conditions="" - for ignored_file in "${ignored_files[@]}"; do - exclude_conditions=" $exclude_conditions ! -name \"$ignored_file\"" - done - - eval find . -mindepth 1 -maxdepth 1 $exclude_conditions -exec rm -rf {} + - - # TODO move to actions - # TODO need to separete .github/workflows/synchronization.yaml into personal directory - - name: Sync files to remote repository - env: - SYNC_IGNORE: ${{ inputs.syncIgnore }} - run: | - IFS=',' read -r -a ignored_files <<< "$SYNC_IGNORE" - - exclude_conditions="" - for ignored_file in "${ignored_files[@]}"; do - exclude_conditions=" $exclude_conditions --exclude \"$ignored_file\"" - done - - echo $exclude_conditions - - eval rsync -av --progress "$SOURCE_TMP_DIR_PATH" "$TARGET_TMP_DIR_PATH" $exclude_conditions - - # TODO move to actions - - name: Apply changes to files - working-directory: ${{ env.TARGET_TMP_DIR_PATH }} - env: - REPLACMENT_EXTENTIONS: ${{ inputs.replacementExtentions }} - REPLACEMENT_CONTENTS: ${{ inputs.replacementContents }} - run: | - IFS=',' read -r -a replacement_extentions <<< "$REPLACMENT_EXTENTIONS" - IFS=',' read -r -a replacement_contents <<< "$REPLACEMENT_CONTENTS" - - find_conditions="" - for extention in "${replacement_extentions[@]}"; do - if [ -z "$find_conditions" ]; then - find_conditions="-name \"$extention\"" - else - find_conditions="$find_conditions -o -name \"$extention\"" - fi - done - - sed_arguments="" - for replacement_content in "${replacement_contents[@]}"; do - sed_arguments+="-e 's|$replacement_content|g' " - done - - eval "find . -type f \( $find_conditions \) -exec sed -i $sed_arguments" {} + - - # TODO move to actions - - name: Rename directories - working-directory: ${{ TARGET_TMP_DIR_PATH }} - run: | - find . -depth -type d -iname '*${{ inputs.sourceDirname }}*' -exec bash -c ' - for dir; do - newdir=$(echo "$dir" | sed -e "s/${{ inputs.sourceDirname }}/${{ inputs.targetDirname }}/gi") - if [ "$dir" != "$newdir" ]; then - echo "Renaming directory: $dir -> $newdir" - mv "$dir" "$newdir" - fi - done - ' bash {} + - - # TODO move to actions + - uses: rees46/workflow/.github/actions/utils/fs/clean-dir@master + with: + targetDirectory: ${{ env.TARGET_TMP_DIR_PATH }} + syncIgnore: ${{ inputs.syncIgnore }} + + - uses: rees46/workflow/.github/actions/utils/fs/sync-dirs@master + with: + syncIgnore: ${{ inputs.syncIgnore }} + targetDirectory: ${{ env.TARGET_TMP_DIR_PATH }} + sourceDirectory: ${{ env.SOURCE_TMP_DIR_PATH }} + + - uses: rees46/workflow/.github/actions/utils/fs/replace-file-content@master + with: + syncIgnore: ${{ inputs.syncIgnore }} + targetDirectory: ${{ env.TARGET_TMP_DIR_PATH }} + replacementExtentions: ${{ inputs.replacementExtentions }} + replacementContents: ${{ inputs.replacementContents }} + + - uses: rees46/workflow/.github/actions/utils/fs/rename-dirs@master + with: + targetDirectory: ${{ env.TARGET_TMP_DIR_PATH }} + sourceDirname: ${{ inputs.sourceDirname }} + targetDirname: ${{ inputs.targetDirname }} + # TODO why not delete tmp? - - name: Copy files from targe dir - run: | - rsync -a "$TARGET_TMP_DIR_PATH" . + - uses: rees46/workflow/.github/actions/utils/fs/sync-dirs@master + with: + targetDirectory: ${{ env.TARGET_TMP_DIR_PATH }} + sourceDirectory: . - uses: rees46/workflow/.github/actions/github/pull-request/get-last-author@master id: lastPrAuthorStep From 609ae19dd563cfc08f9a047c46c5f10eba07925f Mon Sep 17 00:00:00 2001 From: kirill ivanov Date: Wed, 2 Apr 2025 15:07:22 +0300 Subject: [PATCH 11/22] feat(github): make dirnames optional --- .github/workflows/reusable-android-synchronization.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/reusable-android-synchronization.yaml b/.github/workflows/reusable-android-synchronization.yaml index f36339ee..78d8b37d 100644 --- a/.github/workflows/reusable-android-synchronization.yaml +++ b/.github/workflows/reusable-android-synchronization.yaml @@ -15,10 +15,8 @@ on: required: true sourceDirname: type: string - required: true targetDirname: type: string - required: true syncIgnore: type: string required: true @@ -83,6 +81,7 @@ jobs: replacementContents: ${{ inputs.replacementContents }} - uses: rees46/workflow/.github/actions/utils/fs/rename-dirs@master + if: ${{ inputs.sourceDirname != '' && targetDirname != '' }} with: targetDirectory: ${{ env.TARGET_TMP_DIR_PATH }} sourceDirname: ${{ inputs.sourceDirname }} From 7194876ada068f725ca2700555f00aeda443b0bf Mon Sep 17 00:00:00 2001 From: kirill ivanov Date: Thu, 3 Apr 2025 12:19:36 +0300 Subject: [PATCH 12/22] chore(github): change actions branch from master to current dev branch --- .../reusable-android-synchronization.yaml | 33 ++++++++++++------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/.github/workflows/reusable-android-synchronization.yaml b/.github/workflows/reusable-android-synchronization.yaml index 78d8b37d..57b3c308 100644 --- a/.github/workflows/reusable-android-synchronization.yaml +++ b/.github/workflows/reusable-android-synchronization.yaml @@ -62,25 +62,29 @@ jobs: token: ${{ steps.appTokenStep.outputs.token }} repository: ${{inputs.targetRepository}} - - uses: rees46/workflow/.github/actions/utils/fs/clean-dir@master + # - uses: rees46/workflow/.github/actions/utils/fs/clean-dir@master + - uses: rees46/workflow/.github/actions/utils/fs/clean-dir@refactor/reusable-android-synchronization with: targetDirectory: ${{ env.TARGET_TMP_DIR_PATH }} syncIgnore: ${{ inputs.syncIgnore }} - - uses: rees46/workflow/.github/actions/utils/fs/sync-dirs@master + # - uses: rees46/workflow/.github/actions/utils/fs/sync-dirs@master + - uses: rees46/workflow/.github/actions/utils/fs/sync-dirs@refactor/reusable-android-synchronization with: syncIgnore: ${{ inputs.syncIgnore }} targetDirectory: ${{ env.TARGET_TMP_DIR_PATH }} sourceDirectory: ${{ env.SOURCE_TMP_DIR_PATH }} - - uses: rees46/workflow/.github/actions/utils/fs/replace-file-content@master + # - uses: rees46/workflow/.github/actions/utils/fs/replace-file-content@master + - uses: rees46/workflow/.github/actions/utils/fs/replace-file-content@refactor/reusable-android-synchronization with: syncIgnore: ${{ inputs.syncIgnore }} targetDirectory: ${{ env.TARGET_TMP_DIR_PATH }} replacementExtentions: ${{ inputs.replacementExtentions }} replacementContents: ${{ inputs.replacementContents }} - - uses: rees46/workflow/.github/actions/utils/fs/rename-dirs@master + # - uses: rees46/workflow/.github/actions/utils/fs/rename-dirs@master + - uses: rees46/workflow/.github/actions/utils/fs/rename-dirs@refactor/reusable-android-synchronization if: ${{ inputs.sourceDirname != '' && targetDirname != '' }} with: targetDirectory: ${{ env.TARGET_TMP_DIR_PATH }} @@ -88,35 +92,42 @@ jobs: targetDirname: ${{ inputs.targetDirname }} # TODO why not delete tmp? - - uses: rees46/workflow/.github/actions/utils/fs/sync-dirs@master + # - uses: rees46/workflow/.github/actions/utils/fs/sync-dirs@master + - uses: rees46/workflow/.github/actions/utils/fs/sync-dirs@refactor/reusable-android-synchronization with: targetDirectory: ${{ env.TARGET_TMP_DIR_PATH }} sourceDirectory: . - - uses: rees46/workflow/.github/actions/github/pull-request/get-last-author@master + # - uses: rees46/workflow/.github/actions/github/pull-request/get-last-author@master + - uses: rees46/workflow/.github/actions/github/pull-request/get-last-author@refactor/reusable-android-synchronization id: lastPrAuthorStep with: githubToken: ${{ steps.appTokenStep.outputs.token }} - - uses: rees46/workflow/.github/actions/github/utils/get-new-branch-name@master + # - uses: rees46/workflow/.github/actions/github/utils/get-new-branch-name@master + - uses: rees46/workflow/.github/actions/github/utils/get-new-branch-name@refactor/reusable-android-synchronization id: newBranchNameStep - - uses: rees46/workflow/.github/actions/github/checkout/new-branch@master + # - uses: rees46/workflow/.github/actions/github/checkout/new-branch@master + - uses: rees46/workflow/.github/actions/github/checkout/new-branch@refactor/reusable-android-synchronization with: branchName: ${{ steps.newBranchNameStep.outputs.branchName }} - - uses: rees46/workflow/.github/actions/github/push/create@master + # - uses: rees46/workflow/.github/actions/github/push/create@master + - uses: rees46/workflow/.github/actions/github/push/create@refactor/reusable-android-synchronization with: branchName: ${{ steps.newBranchNameStep.outputs.branchName }} githubToken: ${{ steps.appTokenStep.outputs.token }} - - uses: rees46/workflow/.github/actions/github/commit/create@master + # - uses: rees46/workflow/.github/actions/github/commit/create@master + - uses: rees46/workflow/.github/actions/github/commit/create@refactor/reusable-android-synchronization with: branchName: ${{ steps.newBranchNameStep.outputs.branchName }} githubToken: ${{ steps.appTokenStep.outputs.token }} targetRepository: ${{ env.TARGET_REPO }} - - uses: rees46/workflow/.github/actions/github/pull-request/create@master + # - uses: rees46/workflow/.github/actions/github/pull-request/create@master + - uses: rees46/workflow/.github/actions/github/pull-request/create@refactor/reusable-android-synchronization with: githubToken: ${{ steps.appTokenStep.outputs.token }} lastPrAuthor: ${{ steps.lastPrAuthorStep.outputs.lastPrAuthor }} From 4b334a3779fae19ff17a203d26a408d245000c3e Mon Sep 17 00:00:00 2001 From: kirill ivanov Date: Thu, 3 Apr 2025 12:24:16 +0300 Subject: [PATCH 13/22] fix(github): inputs usage --- .github/workflows/reusable-android-synchronization.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/reusable-android-synchronization.yaml b/.github/workflows/reusable-android-synchronization.yaml index 57b3c308..3e7eb2ed 100644 --- a/.github/workflows/reusable-android-synchronization.yaml +++ b/.github/workflows/reusable-android-synchronization.yaml @@ -85,7 +85,7 @@ jobs: # - uses: rees46/workflow/.github/actions/utils/fs/rename-dirs@master - uses: rees46/workflow/.github/actions/utils/fs/rename-dirs@refactor/reusable-android-synchronization - if: ${{ inputs.sourceDirname != '' && targetDirname != '' }} + if: ${{ inputs.sourceDirname != '' && inputs.targetDirname != '' }} with: targetDirectory: ${{ env.TARGET_TMP_DIR_PATH }} sourceDirname: ${{ inputs.sourceDirname }} From 3db968311232ab5fa5c4f14fbac345e22d1f5140 Mon Sep 17 00:00:00 2001 From: kirill ivanov Date: Thu, 3 Apr 2025 12:26:00 +0300 Subject: [PATCH 14/22] fix(github): secrets usage --- .github/workflows/reusable-android-synchronization.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/reusable-android-synchronization.yaml b/.github/workflows/reusable-android-synchronization.yaml index 3e7eb2ed..bfaa3677 100644 --- a/.github/workflows/reusable-android-synchronization.yaml +++ b/.github/workflows/reusable-android-synchronization.yaml @@ -44,8 +44,8 @@ jobs: - uses: actions/create-github-app-token@v1 id: appTokenStep with: - app-id: ${{ vars.PERSONACLICK_COURIER_ID }} - private-key: ${{ secrets.PERSONACLICK_COURIER_SECRET }} + app-id: ${{ inputs.appId }} + private-key: ${{ secrets.privateKey }} # TODO if need - provide it # owner: PersonaClick From 505215a7c8c48e65f847dd83ee18d0f4384f7e19 Mon Sep 17 00:00:00 2001 From: kirill ivanov Date: Thu, 3 Apr 2025 12:44:28 +0300 Subject: [PATCH 15/22] feat(github): owner to app key --- .github/workflows/reusable-android-synchronization.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/reusable-android-synchronization.yaml b/.github/workflows/reusable-android-synchronization.yaml index bfaa3677..ef254202 100644 --- a/.github/workflows/reusable-android-synchronization.yaml +++ b/.github/workflows/reusable-android-synchronization.yaml @@ -47,7 +47,7 @@ jobs: app-id: ${{ inputs.appId }} private-key: ${{ secrets.privateKey }} # TODO if need - provide it - # owner: PersonaClick + owner: PersonaClick - name: Checkout uses: actions/checkout@v4 From 906b8f6e96244e914f1366063969f63902bf1c89 Mon Sep 17 00:00:00 2001 From: kirill ivanov Date: Thu, 3 Apr 2025 12:47:02 +0300 Subject: [PATCH 16/22] fix(github): provide target repo --- .github/workflows/reusable-android-synchronization.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/reusable-android-synchronization.yaml b/.github/workflows/reusable-android-synchronization.yaml index ef254202..4e961b42 100644 --- a/.github/workflows/reusable-android-synchronization.yaml +++ b/.github/workflows/reusable-android-synchronization.yaml @@ -46,7 +46,7 @@ jobs: with: app-id: ${{ inputs.appId }} private-key: ${{ secrets.privateKey }} - # TODO if need - provide it + # TODO move it into inputs owner: PersonaClick - name: Checkout @@ -124,7 +124,7 @@ jobs: with: branchName: ${{ steps.newBranchNameStep.outputs.branchName }} githubToken: ${{ steps.appTokenStep.outputs.token }} - targetRepository: ${{ env.TARGET_REPO }} + targetRepository: ${{ inputs.targetRepository }} # - uses: rees46/workflow/.github/actions/github/pull-request/create@master - uses: rees46/workflow/.github/actions/github/pull-request/create@refactor/reusable-android-synchronization From 3e38f721e67ec26566879619f3c8653d8f1cfb42 Mon Sep 17 00:00:00 2001 From: kirill ivanov Date: Thu, 3 Apr 2025 12:52:45 +0300 Subject: [PATCH 17/22] feat(github): debug steps --- .../reusable-android-synchronization.yaml | 85 +++++++++++-------- 1 file changed, 51 insertions(+), 34 deletions(-) diff --git a/.github/workflows/reusable-android-synchronization.yaml b/.github/workflows/reusable-android-synchronization.yaml index 4e961b42..f8b06459 100644 --- a/.github/workflows/reusable-android-synchronization.yaml +++ b/.github/workflows/reusable-android-synchronization.yaml @@ -98,37 +98,54 @@ jobs: targetDirectory: ${{ env.TARGET_TMP_DIR_PATH }} sourceDirectory: . - # - uses: rees46/workflow/.github/actions/github/pull-request/get-last-author@master - - uses: rees46/workflow/.github/actions/github/pull-request/get-last-author@refactor/reusable-android-synchronization - id: lastPrAuthorStep - with: - githubToken: ${{ steps.appTokenStep.outputs.token }} - - # - uses: rees46/workflow/.github/actions/github/utils/get-new-branch-name@master - - uses: rees46/workflow/.github/actions/github/utils/get-new-branch-name@refactor/reusable-android-synchronization - id: newBranchNameStep - - # - uses: rees46/workflow/.github/actions/github/checkout/new-branch@master - - uses: rees46/workflow/.github/actions/github/checkout/new-branch@refactor/reusable-android-synchronization - with: - branchName: ${{ steps.newBranchNameStep.outputs.branchName }} - - # - uses: rees46/workflow/.github/actions/github/push/create@master - - uses: rees46/workflow/.github/actions/github/push/create@refactor/reusable-android-synchronization - with: - branchName: ${{ steps.newBranchNameStep.outputs.branchName }} - githubToken: ${{ steps.appTokenStep.outputs.token }} - - # - uses: rees46/workflow/.github/actions/github/commit/create@master - - uses: rees46/workflow/.github/actions/github/commit/create@refactor/reusable-android-synchronization - with: - branchName: ${{ steps.newBranchNameStep.outputs.branchName }} - githubToken: ${{ steps.appTokenStep.outputs.token }} - targetRepository: ${{ inputs.targetRepository }} - - # - uses: rees46/workflow/.github/actions/github/pull-request/create@master - - uses: rees46/workflow/.github/actions/github/pull-request/create@refactor/reusable-android-synchronization - with: - githubToken: ${{ steps.appTokenStep.outputs.token }} - lastPrAuthor: ${{ steps.lastPrAuthorStep.outputs.lastPrAuthor }} - branchName: ${{ steps.newBranchNameStep.outputs.branchName }} + - name: Debug fs + run: | + ls -a + + - name: Debug fs + run: | + ls -a -R + + - name: Debug git + run: | + git status + + - name: Debug git + run: | + git diff + + # # - uses: rees46/workflow/.github/actions/github/pull-request/get-last-author@master + # - uses: rees46/workflow/.github/actions/github/pull-request/get-last-author@refactor/reusable-android-synchronization + # id: lastPrAuthorStep + # with: + # githubToken: ${{ steps.appTokenStep.outputs.token }} + # + # # - uses: rees46/workflow/.github/actions/github/utils/get-new-branch-name@master + # - uses: rees46/workflow/.github/actions/github/utils/get-new-branch-name@refactor/reusable-android-synchronization + # id: newBranchNameStep + # + # # - uses: rees46/workflow/.github/actions/github/checkout/new-branch@master + # - uses: rees46/workflow/.github/actions/github/checkout/new-branch@refactor/reusable-android-synchronization + # with: + # branchName: ${{ steps.newBranchNameStep.outputs.branchName }} + + # # - uses: rees46/workflow/.github/actions/github/commit/create@master + # - uses: rees46/workflow/.github/actions/github/commit/create@refactor/reusable-android-synchronization + # with: + # branchName: ${{ steps.newBranchNameStep.outputs.branchName }} + # githubToken: ${{ steps.appTokenStep.outputs.token }} + # targetRepository: ${{ inputs.targetRepository }} + # + # # - uses: rees46/workflow/.github/actions/github/push/create@master + # - uses: rees46/workflow/.github/actions/github/push/create@refactor/reusable-android-synchronization + # with: + # branchName: ${{ steps.newBranchNameStep.outputs.branchName }} + # githubToken: ${{ steps.appTokenStep.outputs.token }} + # + # + # # - uses: rees46/workflow/.github/actions/github/pull-request/create@master + # - uses: rees46/workflow/.github/actions/github/pull-request/create@refactor/reusable-android-synchronization + # with: + # githubToken: ${{ steps.appTokenStep.outputs.token }} + # lastPrAuthor: ${{ steps.lastPrAuthorStep.outputs.lastPrAuthor }} + # branchName: ${{ steps.newBranchNameStep.outputs.branchName }} From a41120dfb2657dfd0731d71b519493ff398d0de7 Mon Sep 17 00:00:00 2001 From: kirill ivanov Date: Thu, 3 Apr 2025 12:57:19 +0300 Subject: [PATCH 18/22] feat(github): debug steps --- .github/workflows/reusable-android-synchronization.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/reusable-android-synchronization.yaml b/.github/workflows/reusable-android-synchronization.yaml index f8b06459..facd36de 100644 --- a/.github/workflows/reusable-android-synchronization.yaml +++ b/.github/workflows/reusable-android-synchronization.yaml @@ -62,6 +62,10 @@ jobs: token: ${{ steps.appTokenStep.outputs.token }} repository: ${{inputs.targetRepository}} + - name: Debug fs + run: | + ls -a + # - uses: rees46/workflow/.github/actions/utils/fs/clean-dir@master - uses: rees46/workflow/.github/actions/utils/fs/clean-dir@refactor/reusable-android-synchronization with: From 86b381194a44c6234b62c74fa659593276442693 Mon Sep 17 00:00:00 2001 From: kirill ivanov Date: Thu, 3 Apr 2025 12:59:58 +0300 Subject: [PATCH 19/22] fix(github): sync dirs --- .github/actions/utils/fs/sync-dirs/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/utils/fs/sync-dirs/action.yml b/.github/actions/utils/fs/sync-dirs/action.yml index b434e954..a2f55a03 100644 --- a/.github/actions/utils/fs/sync-dirs/action.yml +++ b/.github/actions/utils/fs/sync-dirs/action.yml @@ -40,4 +40,4 @@ runs: if: ${{ inputs.syncIgnore == '' }} shell: bash run: | - rsync -a "${{ inputs.targetDirectory }}" "${{ inputs.sourceDirectory }}" + rsync -a "${{ inputs.sourceDirectory }}" "${{ inputs.targetDirectory }}" From 0efa0add2271f12f211709e2dcd98ea19d8cdfce Mon Sep 17 00:00:00 2001 From: kirill ivanov Date: Thu, 3 Apr 2025 13:02:17 +0300 Subject: [PATCH 20/22] fix(github): sync dirs --- .../reusable-android-synchronization.yaml | 158 +++++++++--------- 1 file changed, 82 insertions(+), 76 deletions(-) diff --git a/.github/workflows/reusable-android-synchronization.yaml b/.github/workflows/reusable-android-synchronization.yaml index facd36de..53c0ee9b 100644 --- a/.github/workflows/reusable-android-synchronization.yaml +++ b/.github/workflows/reusable-android-synchronization.yaml @@ -62,94 +62,100 @@ jobs: token: ${{ steps.appTokenStep.outputs.token }} repository: ${{inputs.targetRepository}} - - name: Debug fs + - name: Sync files to remote repository + if: ${{ inputs.syncIgnore == '' }} run: | - ls -a - - # - uses: rees46/workflow/.github/actions/utils/fs/clean-dir@master - - uses: rees46/workflow/.github/actions/utils/fs/clean-dir@refactor/reusable-android-synchronization - with: - targetDirectory: ${{ env.TARGET_TMP_DIR_PATH }} - syncIgnore: ${{ inputs.syncIgnore }} - - # - uses: rees46/workflow/.github/actions/utils/fs/sync-dirs@master - - uses: rees46/workflow/.github/actions/utils/fs/sync-dirs@refactor/reusable-android-synchronization - with: - syncIgnore: ${{ inputs.syncIgnore }} - targetDirectory: ${{ env.TARGET_TMP_DIR_PATH }} - sourceDirectory: ${{ env.SOURCE_TMP_DIR_PATH }} - - # - uses: rees46/workflow/.github/actions/utils/fs/replace-file-content@master - - uses: rees46/workflow/.github/actions/utils/fs/replace-file-content@refactor/reusable-android-synchronization - with: - syncIgnore: ${{ inputs.syncIgnore }} - targetDirectory: ${{ env.TARGET_TMP_DIR_PATH }} - replacementExtentions: ${{ inputs.replacementExtentions }} - replacementContents: ${{ inputs.replacementContents }} - - # - uses: rees46/workflow/.github/actions/utils/fs/rename-dirs@master - - uses: rees46/workflow/.github/actions/utils/fs/rename-dirs@refactor/reusable-android-synchronization - if: ${{ inputs.sourceDirname != '' && inputs.targetDirname != '' }} - with: - targetDirectory: ${{ env.TARGET_TMP_DIR_PATH }} - sourceDirname: ${{ inputs.sourceDirname }} - targetDirname: ${{ inputs.targetDirname }} - - # TODO why not delete tmp? - # - uses: rees46/workflow/.github/actions/utils/fs/sync-dirs@master - - uses: rees46/workflow/.github/actions/utils/fs/sync-dirs@refactor/reusable-android-synchronization - with: - targetDirectory: ${{ env.TARGET_TMP_DIR_PATH }} - sourceDirectory: . + # rsync -a "${{ inputs.sourceDirectory }}" "${{ inputs.targetDirectory }}" + rsync -a "${{ env.TARGET_TMP_DIR_PATH }}" . - name: Debug fs run: | ls -a - - name: Debug fs - run: | - ls -a -R - - - name: Debug git - run: | - git status - - - name: Debug git - run: | - git diff - - # # - uses: rees46/workflow/.github/actions/github/pull-request/get-last-author@master - # - uses: rees46/workflow/.github/actions/github/pull-request/get-last-author@refactor/reusable-android-synchronization - # id: lastPrAuthorStep + # # - uses: rees46/workflow/.github/actions/utils/fs/clean-dir@master + # - uses: rees46/workflow/.github/actions/utils/fs/clean-dir@refactor/reusable-android-synchronization # with: - # githubToken: ${{ steps.appTokenStep.outputs.token }} + # targetDirectory: ${{ env.TARGET_TMP_DIR_PATH }} + # syncIgnore: ${{ inputs.syncIgnore }} # - # # - uses: rees46/workflow/.github/actions/github/utils/get-new-branch-name@master - # - uses: rees46/workflow/.github/actions/github/utils/get-new-branch-name@refactor/reusable-android-synchronization - # id: newBranchNameStep + # # - uses: rees46/workflow/.github/actions/utils/fs/sync-dirs@master + # - uses: rees46/workflow/.github/actions/utils/fs/sync-dirs@refactor/reusable-android-synchronization + # with: + # syncIgnore: ${{ inputs.syncIgnore }} + # targetDirectory: ${{ env.TARGET_TMP_DIR_PATH }} + # sourceDirectory: ${{ env.SOURCE_TMP_DIR_PATH }} # - # # - uses: rees46/workflow/.github/actions/github/checkout/new-branch@master - # - uses: rees46/workflow/.github/actions/github/checkout/new-branch@refactor/reusable-android-synchronization + # # - uses: rees46/workflow/.github/actions/utils/fs/replace-file-content@master + # - uses: rees46/workflow/.github/actions/utils/fs/replace-file-content@refactor/reusable-android-synchronization # with: - # branchName: ${{ steps.newBranchNameStep.outputs.branchName }} - - # # - uses: rees46/workflow/.github/actions/github/commit/create@master - # - uses: rees46/workflow/.github/actions/github/commit/create@refactor/reusable-android-synchronization + # syncIgnore: ${{ inputs.syncIgnore }} + # targetDirectory: ${{ env.TARGET_TMP_DIR_PATH }} + # replacementExtentions: ${{ inputs.replacementExtentions }} + # replacementContents: ${{ inputs.replacementContents }} + # + # # - uses: rees46/workflow/.github/actions/utils/fs/rename-dirs@master + # - uses: rees46/workflow/.github/actions/utils/fs/rename-dirs@refactor/reusable-android-synchronization + # if: ${{ inputs.sourceDirname != '' && inputs.targetDirname != '' }} # with: - # branchName: ${{ steps.newBranchNameStep.outputs.branchName }} - # githubToken: ${{ steps.appTokenStep.outputs.token }} - # targetRepository: ${{ inputs.targetRepository }} + # targetDirectory: ${{ env.TARGET_TMP_DIR_PATH }} + # sourceDirname: ${{ inputs.sourceDirname }} + # targetDirname: ${{ inputs.targetDirname }} # - # # - uses: rees46/workflow/.github/actions/github/push/create@master - # - uses: rees46/workflow/.github/actions/github/push/create@refactor/reusable-android-synchronization + # # TODO why not delete tmp? + # # - uses: rees46/workflow/.github/actions/utils/fs/sync-dirs@master + # - uses: rees46/workflow/.github/actions/utils/fs/sync-dirs@refactor/reusable-android-synchronization # with: - # branchName: ${{ steps.newBranchNameStep.outputs.branchName }} - # githubToken: ${{ steps.appTokenStep.outputs.token }} + # targetDirectory: ${{ env.TARGET_TMP_DIR_PATH }} + # sourceDirectory: . # + # - name: Debug fs + # run: | + # ls -a # - # # - uses: rees46/workflow/.github/actions/github/pull-request/create@master - # - uses: rees46/workflow/.github/actions/github/pull-request/create@refactor/reusable-android-synchronization - # with: - # githubToken: ${{ steps.appTokenStep.outputs.token }} - # lastPrAuthor: ${{ steps.lastPrAuthorStep.outputs.lastPrAuthor }} - # branchName: ${{ steps.newBranchNameStep.outputs.branchName }} + # - name: Debug fs + # run: | + # ls -a -R + # + # - name: Debug git + # run: | + # git status + # + # - name: Debug git + # run: | + # git diff + # + # # # - uses: rees46/workflow/.github/actions/github/pull-request/get-last-author@master + # # - uses: rees46/workflow/.github/actions/github/pull-request/get-last-author@refactor/reusable-android-synchronization + # # id: lastPrAuthorStep + # # with: + # # githubToken: ${{ steps.appTokenStep.outputs.token }} + # # + # # # - uses: rees46/workflow/.github/actions/github/utils/get-new-branch-name@master + # # - uses: rees46/workflow/.github/actions/github/utils/get-new-branch-name@refactor/reusable-android-synchronization + # # id: newBranchNameStep + # # + # # # - uses: rees46/workflow/.github/actions/github/checkout/new-branch@master + # # - uses: rees46/workflow/.github/actions/github/checkout/new-branch@refactor/reusable-android-synchronization + # # with: + # # branchName: ${{ steps.newBranchNameStep.outputs.branchName }} + # + # # # - uses: rees46/workflow/.github/actions/github/commit/create@master + # # - uses: rees46/workflow/.github/actions/github/commit/create@refactor/reusable-android-synchronization + # # with: + # # branchName: ${{ steps.newBranchNameStep.outputs.branchName }} + # # githubToken: ${{ steps.appTokenStep.outputs.token }} + # # targetRepository: ${{ inputs.targetRepository }} + # # + # # # - uses: rees46/workflow/.github/actions/github/push/create@master + # # - uses: rees46/workflow/.github/actions/github/push/create@refactor/reusable-android-synchronization + # # with: + # # branchName: ${{ steps.newBranchNameStep.outputs.branchName }} + # # githubToken: ${{ steps.appTokenStep.outputs.token }} + # # + # # + # # # - uses: rees46/workflow/.github/actions/github/pull-request/create@master + # # - uses: rees46/workflow/.github/actions/github/pull-request/create@refactor/reusable-android-synchronization + # # with: + # # githubToken: ${{ steps.appTokenStep.outputs.token }} + # # lastPrAuthor: ${{ steps.lastPrAuthorStep.outputs.lastPrAuthor }} + # # branchName: ${{ steps.newBranchNameStep.outputs.branchName }} From 85305554b53cd6290667f9ee51c0ecdb5cb6f909 Mon Sep 17 00:00:00 2001 From: kirill ivanov Date: Thu, 3 Apr 2025 13:03:11 +0300 Subject: [PATCH 21/22] chore(github): useless chore(github): useless chore(github): useless chore(github): useless chore(github): useless chore(github): useless chore(github): useless chore(github): useless chore(github): useless chore(github): useless chore(github): useless chore(github): useless chore(github): useless chore(github): useless chore(github): useless chore(github): useless chore(github): useless chore(github): useless chore(github): useless chore(github): useless chore(github): useless chore(github): useless chore(github): useless chore(github): useless --- .github/actions/utils/fs/clean-dir/action.yml | 7 +- .github/actions/utils/fs/sync-dirs/action.yml | 2 +- .../reusable-android-synchronization.yaml | 174 ++++++++---------- 3 files changed, 86 insertions(+), 97 deletions(-) diff --git a/.github/actions/utils/fs/clean-dir/action.yml b/.github/actions/utils/fs/clean-dir/action.yml index 650e8802..f65c33b5 100644 --- a/.github/actions/utils/fs/clean-dir/action.yml +++ b/.github/actions/utils/fs/clean-dir/action.yml @@ -25,7 +25,10 @@ runs: exclude_conditions="" for ignored_file in "${ignored_files[@]}"; do - exclude_conditions=" $exclude_conditions ! -name \"$ignored_file\"" + exclude_conditions=" $exclude_conditions ! -path \"./$ignored_file/*\" ! -path \"./$ignored_file\"" done - eval find . -mindepth 1 -maxdepth 1 $exclude_conditions -exec rm -rf {} + + echo "$exclude_conditions" + + eval find . -mindepth 1 $exclude_conditions -type f -exec rm -f {} + + find . -mindepth 1 -type d -empty -delete diff --git a/.github/actions/utils/fs/sync-dirs/action.yml b/.github/actions/utils/fs/sync-dirs/action.yml index a2f55a03..44ec78cd 100644 --- a/.github/actions/utils/fs/sync-dirs/action.yml +++ b/.github/actions/utils/fs/sync-dirs/action.yml @@ -40,4 +40,4 @@ runs: if: ${{ inputs.syncIgnore == '' }} shell: bash run: | - rsync -a "${{ inputs.sourceDirectory }}" "${{ inputs.targetDirectory }}" + rsync -av --progress "${{ inputs.targetDirectory }}" "${{ inputs.sourceDirectory }}" diff --git a/.github/workflows/reusable-android-synchronization.yaml b/.github/workflows/reusable-android-synchronization.yaml index 53c0ee9b..b7ad89b1 100644 --- a/.github/workflows/reusable-android-synchronization.yaml +++ b/.github/workflows/reusable-android-synchronization.yaml @@ -1,8 +1,8 @@ name: Sync Android Repositories env: - TARGET_TMP_DIR_PATH: tmp/target - SOURCE_TMP_DIR_PATH: tmp/source + TARGET_TMP_DIR_PATH: tmp/target/ + SOURCE_TMP_DIR_PATH: tmp/source/ on: workflow_call: @@ -62,100 +62,86 @@ jobs: token: ${{ steps.appTokenStep.outputs.token }} repository: ${{inputs.targetRepository}} - - name: Sync files to remote repository - if: ${{ inputs.syncIgnore == '' }} - run: | - # rsync -a "${{ inputs.sourceDirectory }}" "${{ inputs.targetDirectory }}" - rsync -a "${{ env.TARGET_TMP_DIR_PATH }}" . + # - uses: rees46/workflow/.github/actions/utils/fs/clean-dir@master + - uses: rees46/workflow/.github/actions/utils/fs/clean-dir@refactor/reusable-android-synchronization + with: + targetDirectory: ${{ env.TARGET_TMP_DIR_PATH }} + syncIgnore: ${{ inputs.syncIgnore }} + + # - uses: rees46/workflow/.github/actions/utils/fs/sync-dirs@master + - uses: rees46/workflow/.github/actions/utils/fs/sync-dirs@refactor/reusable-android-synchronization + with: + syncIgnore: ${{ inputs.syncIgnore }} + targetDirectory: ${{ env.TARGET_TMP_DIR_PATH }} + sourceDirectory: ${{ env.SOURCE_TMP_DIR_PATH }} + + # - uses: rees46/workflow/.github/actions/utils/fs/replace-file-content@master + - uses: rees46/workflow/.github/actions/utils/fs/replace-file-content@refactor/reusable-android-synchronization + with: + syncIgnore: ${{ inputs.syncIgnore }} + targetDirectory: ${{ env.TARGET_TMP_DIR_PATH }} + replacementExtentions: ${{ inputs.replacementExtentions }} + replacementContents: ${{ inputs.replacementContents }} + + # - uses: rees46/workflow/.github/actions/utils/fs/rename-dirs@master + - uses: rees46/workflow/.github/actions/utils/fs/rename-dirs@refactor/reusable-android-synchronization + if: ${{ inputs.sourceDirname != '' && inputs.targetDirname != '' }} + with: + targetDirectory: ${{ env.TARGET_TMP_DIR_PATH }} + sourceDirname: ${{ inputs.sourceDirname }} + targetDirname: ${{ inputs.targetDirname }} + + # TODO why not delete tmp? + # - uses: rees46/workflow/.github/actions/utils/fs/sync-dirs@master + - uses: rees46/workflow/.github/actions/utils/fs/sync-dirs@refactor/reusable-android-synchronization + with: + targetDirectory: ${{ env.TARGET_TMP_DIR_PATH }} + sourceDirectory: . - - name: Debug fs + - name: debug fs after changes run: | ls -a - # # - uses: rees46/workflow/.github/actions/utils/fs/clean-dir@master - # - uses: rees46/workflow/.github/actions/utils/fs/clean-dir@refactor/reusable-android-synchronization - # with: - # targetDirectory: ${{ env.TARGET_TMP_DIR_PATH }} - # syncIgnore: ${{ inputs.syncIgnore }} - # - # # - uses: rees46/workflow/.github/actions/utils/fs/sync-dirs@master - # - uses: rees46/workflow/.github/actions/utils/fs/sync-dirs@refactor/reusable-android-synchronization - # with: - # syncIgnore: ${{ inputs.syncIgnore }} - # targetDirectory: ${{ env.TARGET_TMP_DIR_PATH }} - # sourceDirectory: ${{ env.SOURCE_TMP_DIR_PATH }} - # - # # - uses: rees46/workflow/.github/actions/utils/fs/replace-file-content@master - # - uses: rees46/workflow/.github/actions/utils/fs/replace-file-content@refactor/reusable-android-synchronization - # with: - # syncIgnore: ${{ inputs.syncIgnore }} - # targetDirectory: ${{ env.TARGET_TMP_DIR_PATH }} - # replacementExtentions: ${{ inputs.replacementExtentions }} - # replacementContents: ${{ inputs.replacementContents }} - # - # # - uses: rees46/workflow/.github/actions/utils/fs/rename-dirs@master - # - uses: rees46/workflow/.github/actions/utils/fs/rename-dirs@refactor/reusable-android-synchronization - # if: ${{ inputs.sourceDirname != '' && inputs.targetDirname != '' }} - # with: - # targetDirectory: ${{ env.TARGET_TMP_DIR_PATH }} - # sourceDirname: ${{ inputs.sourceDirname }} - # targetDirname: ${{ inputs.targetDirname }} - # - # # TODO why not delete tmp? - # # - uses: rees46/workflow/.github/actions/utils/fs/sync-dirs@master - # - uses: rees46/workflow/.github/actions/utils/fs/sync-dirs@refactor/reusable-android-synchronization + - name: debug fs after changes + run: | + ls -a -R + + # - uses: rees46/workflow/.github/actions/github/pull-request/get-last-author@master + # TODO provide source directory + - uses: rees46/workflow/.github/actions/github/pull-request/get-last-author@refactor/reusable-android-synchronization + id: lastPrAuthorStep + with: + githubToken: ${{ steps.appTokenStep.outputs.token }} + + # - uses: rees46/workflow/.github/actions/github/utils/get-new-branch-name@master + - uses: rees46/workflow/.github/actions/github/utils/get-new-branch-name@refactor/reusable-android-synchronization + id: newBranchNameStep + + # - uses: rees46/workflow/.github/actions/github/checkout/new-branch@master + - uses: rees46/workflow/.github/actions/github/checkout/new-branch@refactor/reusable-android-synchronization + with: + branchName: ${{ steps.newBranchNameStep.outputs.branchName }} + + - name: git add + run: | + git add --all -- . ':!tmp/' + + # - uses: rees46/workflow/.github/actions/github/commit/create@master + - uses: rees46/workflow/.github/actions/github/commit/create@refactor/reusable-android-synchronization + with: + branchName: ${{ steps.newBranchNameStep.outputs.branchName }} + githubToken: ${{ steps.appTokenStep.outputs.token }} + targetRepository: ${{ inputs.targetRepository }} + + # # - uses: rees46/workflow/.github/actions/github/push/create@master + # - uses: rees46/workflow/.github/actions/github/push/create@refactor/reusable-android-synchronization # with: - # targetDirectory: ${{ env.TARGET_TMP_DIR_PATH }} - # sourceDirectory: . - # - # - name: Debug fs - # run: | - # ls -a - # - # - name: Debug fs - # run: | - # ls -a -R - # - # - name: Debug git - # run: | - # git status - # - # - name: Debug git - # run: | - # git diff - # - # # # - uses: rees46/workflow/.github/actions/github/pull-request/get-last-author@master - # # - uses: rees46/workflow/.github/actions/github/pull-request/get-last-author@refactor/reusable-android-synchronization - # # id: lastPrAuthorStep - # # with: - # # githubToken: ${{ steps.appTokenStep.outputs.token }} - # # - # # # - uses: rees46/workflow/.github/actions/github/utils/get-new-branch-name@master - # # - uses: rees46/workflow/.github/actions/github/utils/get-new-branch-name@refactor/reusable-android-synchronization - # # id: newBranchNameStep - # # - # # # - uses: rees46/workflow/.github/actions/github/checkout/new-branch@master - # # - uses: rees46/workflow/.github/actions/github/checkout/new-branch@refactor/reusable-android-synchronization - # # with: - # # branchName: ${{ steps.newBranchNameStep.outputs.branchName }} - # - # # # - uses: rees46/workflow/.github/actions/github/commit/create@master - # # - uses: rees46/workflow/.github/actions/github/commit/create@refactor/reusable-android-synchronization - # # with: - # # branchName: ${{ steps.newBranchNameStep.outputs.branchName }} - # # githubToken: ${{ steps.appTokenStep.outputs.token }} - # # targetRepository: ${{ inputs.targetRepository }} - # # - # # # - uses: rees46/workflow/.github/actions/github/push/create@master - # # - uses: rees46/workflow/.github/actions/github/push/create@refactor/reusable-android-synchronization - # # with: - # # branchName: ${{ steps.newBranchNameStep.outputs.branchName }} - # # githubToken: ${{ steps.appTokenStep.outputs.token }} - # # - # # - # # # - uses: rees46/workflow/.github/actions/github/pull-request/create@master - # # - uses: rees46/workflow/.github/actions/github/pull-request/create@refactor/reusable-android-synchronization - # # with: - # # githubToken: ${{ steps.appTokenStep.outputs.token }} - # # lastPrAuthor: ${{ steps.lastPrAuthorStep.outputs.lastPrAuthor }} - # # branchName: ${{ steps.newBranchNameStep.outputs.branchName }} + # branchName: ${{ steps.newBranchNameStep.outputs.branchName }} + # githubToken: ${{ steps.appTokenStep.outputs.token }} + + # - uses: rees46/workflow/.github/actions/github/pull-request/create@master + - uses: rees46/workflow/.github/actions/github/pull-request/create@refactor/reusable-android-synchronization + with: + githubToken: ${{ steps.appTokenStep.outputs.token }} + lastPrAuthor: ${{ steps.lastPrAuthorStep.outputs.lastPrAuthor }} + branchName: ${{ steps.newBranchNameStep.outputs.branchName }} From 30ebac723240672431e7739cc1ee8a6dda579c05 Mon Sep 17 00:00:00 2001 From: kirill ivanov Date: Thu, 3 Apr 2025 16:48:56 +0300 Subject: [PATCH 22/22] feat(github): prepare for prod --- .../reusable-android-synchronization.yaml | 44 ++++++------------- 1 file changed, 14 insertions(+), 30 deletions(-) diff --git a/.github/workflows/reusable-android-synchronization.yaml b/.github/workflows/reusable-android-synchronization.yaml index b7ad89b1..163f1776 100644 --- a/.github/workflows/reusable-android-synchronization.yaml +++ b/.github/workflows/reusable-android-synchronization.yaml @@ -13,6 +13,9 @@ on: targetRepository: type: string required: true + repositoryOwner: + type: string + required: true sourceDirname: type: string targetDirname: @@ -46,8 +49,7 @@ jobs: with: app-id: ${{ inputs.appId }} private-key: ${{ secrets.privateKey }} - # TODO move it into inputs - owner: PersonaClick + owner: ${{ inputs.repositoryOwner }} - name: Checkout uses: actions/checkout@v4 @@ -62,38 +64,32 @@ jobs: token: ${{ steps.appTokenStep.outputs.token }} repository: ${{inputs.targetRepository}} - # - uses: rees46/workflow/.github/actions/utils/fs/clean-dir@master - - uses: rees46/workflow/.github/actions/utils/fs/clean-dir@refactor/reusable-android-synchronization + - uses: rees46/workflow/.github/actions/utils/fs/clean-dir@master with: targetDirectory: ${{ env.TARGET_TMP_DIR_PATH }} syncIgnore: ${{ inputs.syncIgnore }} - # - uses: rees46/workflow/.github/actions/utils/fs/sync-dirs@master - - uses: rees46/workflow/.github/actions/utils/fs/sync-dirs@refactor/reusable-android-synchronization + - uses: rees46/workflow/.github/actions/utils/fs/sync-dirs@master with: syncIgnore: ${{ inputs.syncIgnore }} targetDirectory: ${{ env.TARGET_TMP_DIR_PATH }} sourceDirectory: ${{ env.SOURCE_TMP_DIR_PATH }} - # - uses: rees46/workflow/.github/actions/utils/fs/replace-file-content@master - - uses: rees46/workflow/.github/actions/utils/fs/replace-file-content@refactor/reusable-android-synchronization + - uses: rees46/workflow/.github/actions/utils/fs/replace-file-content@master with: syncIgnore: ${{ inputs.syncIgnore }} targetDirectory: ${{ env.TARGET_TMP_DIR_PATH }} replacementExtentions: ${{ inputs.replacementExtentions }} replacementContents: ${{ inputs.replacementContents }} - # - uses: rees46/workflow/.github/actions/utils/fs/rename-dirs@master - - uses: rees46/workflow/.github/actions/utils/fs/rename-dirs@refactor/reusable-android-synchronization + - uses: rees46/workflow/.github/actions/utils/fs/rename-dirs@master if: ${{ inputs.sourceDirname != '' && inputs.targetDirname != '' }} with: targetDirectory: ${{ env.TARGET_TMP_DIR_PATH }} sourceDirname: ${{ inputs.sourceDirname }} targetDirname: ${{ inputs.targetDirname }} - # TODO why not delete tmp? - # - uses: rees46/workflow/.github/actions/utils/fs/sync-dirs@master - - uses: rees46/workflow/.github/actions/utils/fs/sync-dirs@refactor/reusable-android-synchronization + - uses: rees46/workflow/.github/actions/utils/fs/sync-dirs@master with: targetDirectory: ${{ env.TARGET_TMP_DIR_PATH }} sourceDirectory: . @@ -106,19 +102,15 @@ jobs: run: | ls -a -R - # - uses: rees46/workflow/.github/actions/github/pull-request/get-last-author@master - # TODO provide source directory - - uses: rees46/workflow/.github/actions/github/pull-request/get-last-author@refactor/reusable-android-synchronization + - uses: rees46/workflow/.github/actions/github/pull-request/get-last-author@master id: lastPrAuthorStep with: githubToken: ${{ steps.appTokenStep.outputs.token }} - # - uses: rees46/workflow/.github/actions/github/utils/get-new-branch-name@master - - uses: rees46/workflow/.github/actions/github/utils/get-new-branch-name@refactor/reusable-android-synchronization + - uses: rees46/workflow/.github/actions/github/utils/get-new-branch-name@master id: newBranchNameStep - # - uses: rees46/workflow/.github/actions/github/checkout/new-branch@master - - uses: rees46/workflow/.github/actions/github/checkout/new-branch@refactor/reusable-android-synchronization + - uses: rees46/workflow/.github/actions/github/checkout/new-branch@master with: branchName: ${{ steps.newBranchNameStep.outputs.branchName }} @@ -126,21 +118,13 @@ jobs: run: | git add --all -- . ':!tmp/' - # - uses: rees46/workflow/.github/actions/github/commit/create@master - - uses: rees46/workflow/.github/actions/github/commit/create@refactor/reusable-android-synchronization + - uses: rees46/workflow/.github/actions/github/commit/create@master with: branchName: ${{ steps.newBranchNameStep.outputs.branchName }} githubToken: ${{ steps.appTokenStep.outputs.token }} targetRepository: ${{ inputs.targetRepository }} - # # - uses: rees46/workflow/.github/actions/github/push/create@master - # - uses: rees46/workflow/.github/actions/github/push/create@refactor/reusable-android-synchronization - # with: - # branchName: ${{ steps.newBranchNameStep.outputs.branchName }} - # githubToken: ${{ steps.appTokenStep.outputs.token }} - - # - uses: rees46/workflow/.github/actions/github/pull-request/create@master - - uses: rees46/workflow/.github/actions/github/pull-request/create@refactor/reusable-android-synchronization + - uses: rees46/workflow/.github/actions/github/pull-request/create@master with: githubToken: ${{ steps.appTokenStep.outputs.token }} lastPrAuthor: ${{ steps.lastPrAuthorStep.outputs.lastPrAuthor }}