From 71a193ca90c28265df9d9844abedf11b5ef17e91 Mon Sep 17 00:00:00 2001 From: kirill ivanov Date: Sat, 29 Mar 2025 07:30:23 +0300 Subject: [PATCH 1/7] 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 a7c630003a73a6eb3e7d148d5316503c11470153 Mon Sep 17 00:00:00 2001 From: kirill ivanov Date: Sun, 30 Mar 2025 19:03:45 +0300 Subject: [PATCH 2/7] 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 e5eba5012007608cfd0046212f2ebe32553c9639 Mon Sep 17 00:00:00 2001 From: kirill ivanov Date: Sun, 30 Mar 2025 21:38:33 +0300 Subject: [PATCH 3/7] 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 f37ab611f8d575e7784a0d09b3b917d0ceedb59c Mon Sep 17 00:00:00 2001 From: kirill ivanov Date: Mon, 31 Mar 2025 14:16:33 +0300 Subject: [PATCH 4/7] 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 33d9a4a882fae6a78a00b526d8062fd13dafa29b Mon Sep 17 00:00:00 2001 From: kirill ivanov Date: Mon, 31 Mar 2025 14:19:20 +0300 Subject: [PATCH 5/7] 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 f55f06d6b80df8273c7b388928e07135732bc0de Mon Sep 17 00:00:00 2001 From: kirill ivanov Date: Tue, 1 Apr 2025 00:03:49 +0300 Subject: [PATCH 6/7] style(github): format --- .github/actions/github/commit/create/action.yml | 2 +- .../workflows/reusable-android-synchronization.yaml | 2 +- .github/workflows/reusable-android-version.yaml | 6 +++--- .github/workflows/reusable-ios-synchronization.yaml | 6 +++--- .github/workflows/reusable-ios-testflight-publish.yaml | 10 +++++----- .github/workflows/reusable-multiplatform-bump.yaml | 6 +++--- .github/workflows/synchronization.yaml | 8 ++++---- 7 files changed, 20 insertions(+), 20 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/reusable-android-synchronization.yaml b/.github/workflows/reusable-android-synchronization.yaml index d40e690a..e31ab271 100644 --- a/.github/workflows/reusable-android-synchronization.yaml +++ b/.github/workflows/reusable-android-synchronization.yaml @@ -25,7 +25,7 @@ jobs: - 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") diff --git a/.github/workflows/reusable-android-version.yaml b/.github/workflows/reusable-android-version.yaml index 6c3dfd09..9e6166df 100644 --- a/.github/workflows/reusable-android-version.yaml +++ b/.github/workflows/reusable-android-version.yaml @@ -6,7 +6,7 @@ on: appId: required: true type: string - description: "App ID for committing and pushing" + description: 'App ID for committing and pushing' secrets: appSecret: required: true @@ -49,5 +49,5 @@ jobs: with: repo: ${{ github.repository }} branch: master - commit_message: "chore(common): version bump to ${{ steps.versionName.outputs.versionName }}" - file_pattern: "personalization-sdk" + commit_message: 'chore(common): version bump to ${{ steps.versionName.outputs.versionName }}' + file_pattern: 'personalization-sdk' diff --git a/.github/workflows/reusable-ios-synchronization.yaml b/.github/workflows/reusable-ios-synchronization.yaml index 048f7f4c..a9065dc1 100644 --- a/.github/workflows/reusable-ios-synchronization.yaml +++ b/.github/workflows/reusable-ios-synchronization.yaml @@ -1,7 +1,7 @@ name: Sync iOS Repositories env: - WORKFLOW_REPO: "rees46/workflow" + WORKFLOW_REPO: 'rees46/workflow' on: workflow_call: @@ -12,11 +12,11 @@ on: targetRepository: type: string required: true - default: "Target repository" + default: 'Target repository' versionFilePath: type: string required: true - default: "version.properties" + default: 'version.properties' jobs: run: diff --git a/.github/workflows/reusable-ios-testflight-publish.yaml b/.github/workflows/reusable-ios-testflight-publish.yaml index a480917d..27998992 100644 --- a/.github/workflows/reusable-ios-testflight-publish.yaml +++ b/.github/workflows/reusable-ios-testflight-publish.yaml @@ -1,10 +1,10 @@ name: Reusable iOS TestFlight Publish env: - WORKFLOW_REPO: "rees46/workflow" - ARCHIVE_EXPORT_PATH: "./build/exported-app" - EXPORT_OPTIONS_PLIST_PATH: "./ExportOptions.plist" - PROPERTIES_FILE: "version.properties" + WORKFLOW_REPO: 'rees46/workflow' + ARCHIVE_EXPORT_PATH: './build/exported-app' + EXPORT_OPTIONS_PLIST_PATH: './ExportOptions.plist' + PROPERTIES_FILE: 'version.properties' on: workflow_call: @@ -144,7 +144,7 @@ jobs: - name: Upload to TestFlight uses: Apple-Actions/upload-testflight-build@master with: - app-path: "${{ env.ARCHIVE_EXPORT_PATH }}/${{ inputs.scheme }}.ipa" + app-path: '${{ env.ARCHIVE_EXPORT_PATH }}/${{ inputs.scheme }}.ipa' issuer-id: ${{ secrets.APP_STORE_CONNECT_ISSUER_ID }} api-key-id: ${{ secrets.APP_STORE_CONNECT_API_KEY_ID }} api-private-key: ${{ secrets.APP_STORE_CONNECT_API_KEY }} diff --git a/.github/workflows/reusable-multiplatform-bump.yaml b/.github/workflows/reusable-multiplatform-bump.yaml index 758fa33e..8f894393 100644 --- a/.github/workflows/reusable-multiplatform-bump.yaml +++ b/.github/workflows/reusable-multiplatform-bump.yaml @@ -1,8 +1,8 @@ name: Reusable multiplatform bump env: - WORKFLOW_REPO: "rees46/workflow" - PROPERTIES_FILE: "version.properties" + WORKFLOW_REPO: 'rees46/workflow' + PROPERTIES_FILE: 'version.properties' on: workflow_call: @@ -58,5 +58,5 @@ jobs: with: repo: ${{ github.repository }} branch: master - commit_message: "chore: bump version to ${{ steps.versionName.outputs.versionName }}" + commit_message: 'chore: bump version to ${{ steps.versionName.outputs.versionName }}' file_pattern: ${{ env.PROPERTIES_FILE }} 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 f2d22f8e0762976430c3f8b58a1dd42fff695606 Mon Sep 17 00:00:00 2001 From: kirill ivanov Date: Tue, 1 Apr 2025 00:06:38 +0300 Subject: [PATCH 7/7] 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 }}