From 0e51714bd42e4ce8223a641d7435c220a99aad51 Mon Sep 17 00:00:00 2001 From: Kevin AUDE <98819045+kevin-aude@users.noreply.github.com> Date: Thu, 25 Jan 2024 12:02:57 +0100 Subject: [PATCH 1/7] feat: allow for pruning of older PRs (#438) * feat: allow for pruning of older PRs * UPDATE main template sync script to support the option to delete older PRs targeting the same branch if a newer one is created * UPDATE README to reflect the change * feat: automatic label creation * UPDATE main template sync script to support the automatic creation of labels and skip PR cleanup if no labels are set * UPDATE README in order to reflect these changes and explain the reasoning behind it * docs: :memo: (#438) add warning about prune old pull requests * style: :rotating_light: (#437) doc lint issue * fix: label emptiness check for PRs cleanup --------- Co-authored-by: andy Augustin Co-authored-by: Andy Augustin --- README.md | 60 ++++++++++++++++--------- action.yml | 5 +++ src/sync_template.sh | 104 ++++++++++++++++++++++++++++++++++++------- 3 files changed, 132 insertions(+), 37 deletions(-) diff --git a/README.md b/README.md index 76b907a6..26b6a6e9 100644 --- a/README.md +++ b/README.md @@ -99,7 +99,7 @@ jobs: github_token: ${{ secrets.GITHUB_TOKEN }} source_repo_path: upstream_branch: # defaults to main - pr_labels: ,[,...] # optional, no default + pr_labels: ,[,...] # defaults to template_sync ``` You will receive a pull request within your repository if there are some changes available in the template. @@ -139,7 +139,7 @@ jobs: github_token: ${{ steps.generate_token.outputs.token }} source_repo_path: upstream_branch: # defaults to main - pr_labels: ,[,...] # optional, no default + pr_labels: ,[,...] # defaults to template_sync ``` #### 2. Using SSH @@ -175,7 +175,7 @@ jobs: github_token: ${{ secrets.GITHUB_TOKEN }} source_repo_path: ${{ secrets.SOURCE_REPO_PATH }} # , should be within secrets upstream_branch: ${{ secrets.TARGET_BRANCH }} # # defaults to main - pr_labels: ,[,...] # optional, no default + pr_labels: ,[,...] # defaults to template_sync source_repo_ssh_private_key: ${{ secrets.SOURCE_REPO_SSH_PRIVATE_KEY }} # contains the private ssh key of the private repository ``` @@ -232,24 +232,25 @@ jobs: ### Configuration parameters -| Variable | Description | Required | `[Default]` | -|----|----|----|----| -| github_token | Token for the repo. Can be passed in using `$\{{ secrets.GITHUB_TOKEN }}` | `true` | | -| source_repo_path | Repository path of the template | `true` | | -| upstream_branch | The target branch | `false` | `` | -| source_repo_ssh_private_key | `[optional]` private ssh key for the source repository. [see](#private-template-repository)| `false` | | -| pr_branch_name_prefix | `[optional]` the prefix of branches created by this action | `false` | `chore/template_sync` | -| pr_title | `[optional]` the title of PRs opened by this action. Must be already created. | `false` | `upstream merge template repository` | -| pr_labels | `[optional]` comma separated list. [pull request labels][pr-labels]. Must be already created. | `false` | | -| pr_reviewers | `[optional]` comma separated list of pull request reviewers. | `false` | | -| pr_commit_msg | `[optional]` commit message in the created pull request | `false` | `chore(template): merge template changes :up:` | -| hostname | `[optional]` the hostname of the repository | `false` | `github.com` | -| is_dry_run | `[optional]` set to `true` if you do not want to push the changes and not want to create a PR | `false` | | -| is_allow_hooks | `[optional]` set to `true` if you want to enable lifecycle hooks. Use this with caution! | `false` | `false` | -| is_not_source_github | `[optional]` set to `true` if the source git provider is not GitHub | `false` | `false` | -| git_user_name | `[optional]` set the committer git user.name | `false` | `${GITHUB_ACTOR}` | -| git_user_email | `[optional]` set the committer git user.email | `false` | `github-action@actions-template-sync.noreply.${SOURCE_REPO_HOSTNAME}` | -| git_remote_pull_params |`[optional]` set remote pull parameters | `false` | `--allow-unrelated-histories --squash --strategy=recursive -X theirs` | +| Variable | Description | Required | `[Default]` | +|-----------------------------|---------------------------------------------------------------------------------------------------------------|----------|-----------------------------------------------------------------------| +| github_token | Token for the repo. Can be passed in using `$\{{ secrets.GITHUB_TOKEN }}` | `true` | | +| source_repo_path | Repository path of the template | `true` | | +| upstream_branch | The target branch | `false` | `` | +| source_repo_ssh_private_key | `[optional]` private ssh key for the source repository. [see](#private-template-repository) | `false` | | +| pr_branch_name_prefix | `[optional]` the prefix of branches created by this action | `false` | `chore/template_sync` | +| pr_title | `[optional]` the title of PRs opened by this action. Must be already created. | `false` | `upstream merge template repository` | +| pr_labels | `[optional]` comma separated list. [pull request labels][pr-labels]. | `false` | `sync_template` | +| pr_reviewers | `[optional]` comma separated list of pull request reviewers. | `false` | | +| pr_commit_msg | `[optional]` commit message in the created pull request | `false` | `chore(template): merge template changes :up:` | +| hostname | `[optional]` the hostname of the repository | `false` | `github.com` | +| is_dry_run | `[optional]` set to `true` if you do not want to push the changes and not want to create a PR | `false` | | +| is_allow_hooks | `[optional]` set to `true` if you want to enable lifecycle hooks. Use this with caution! | `false` | `false` | +| is_pr_cleanup | `[optional]` set to `true` if you want to cleanup older PRs targeting the same branch. Use this with caution! | `false` | `false` | +| is_not_source_github | `[optional]` set to `true` if the source git provider is not GitHub | `false` | `false` | +| git_user_name | `[optional]` set the committer git user.name | `false` | `${GITHUB_ACTOR}` | +| git_user_email | `[optional]` set the committer git user.email | `false` | `github-action@actions-template-sync.noreply.${SOURCE_REPO_HOSTNAME}` | +| git_remote_pull_params | `[optional]` set remote pull parameters | `false` | `--allow-unrelated-histories --squash --strategy=recursive -X theirs` | ### Docker @@ -304,6 +305,7 @@ The following hooks are supported (please check [docs/ARCHITECTURE.md](docs/ARCH * `prepull` is executed before the code is pulled from the source repository * `precommit` is executed before the code is commited * `prepush` is executed before the push is executed, right after the commit +* `precleanup` is executed before older PRs targeting the same branch are closed * `prepr` is executed before the PR is done **Remark** The underlying OS is defined by an Alpine container. @@ -329,12 +331,28 @@ hooks: commands: - echo 'hi, we are within the prepush phase' - echo 'maybe you want to add further changes and commits' + precleanup: + commands: + - echo 'hi, we are within the precleanup phase' + - echo 'maybe you want to interact with older PRs before they are closed' prepr: commands: - echo 'hi, we are within the prepr phase' - echo 'maybe you want to change the code a bit and do another push before creating the pr' ``` +## Labels creation + +By default, generated PRs will be labeled with the `template_sync` label. +If that label doesn't exist in your repository, it will be created automatically unless you specify your own existing labels. +Associating a label with the generated PRs helps keeping track of them and allows for features like automatic PR cleanup. + +## Pull request cleanup + +Depending on your way of working, you may end up with multiple pull requests related to template syncing pointing to the same branch. +If you want to avoid this situation, you can instruct this action to clean up older PRs (search based on labels defined with the `pr_labels` config parameter). +:warning: this feature will close all pull requests with labels configured with `pr_labels` config parameter. + ## Troubleshooting * refusing to allow a GitHub App to create or update workflow `.github/workflows/******.yml` without `workflows` permission diff --git a/action.yml b/action.yml index a4a23b5d..760b5786 100644 --- a/action.yml +++ b/action.yml @@ -23,6 +23,7 @@ inputs: default: "upstream merge template repository" pr_labels: description: "[optional] comma separated list of pull request labels" + default: "template_sync" pr_reviewers: description: "[optional] comma separated list of pull request reviewers" pr_commit_msg: @@ -36,6 +37,9 @@ inputs: is_allow_hooks: description: "[optional] set to true if you want to allow hooks. Use this functionality with caution!" default: "false" + is_pr_cleanup: + description: "[optional] set to true if you want to cleanup older PRs targeting the same branch." + default: "false" is_not_source_github: description: "[optional] set to true if the source repository is not a github related repository. Useful e.q. if the source is GitLab" default: "false" @@ -61,6 +65,7 @@ runs: HOSTNAME: ${{ inputs.hostname }} IS_DRY_RUN: ${{ inputs.is_dry_run }} IS_ALLOW_HOOKS: ${{ inputs.is_allow_hooks }} + IS_PR_CLEANUP: ${{ inputs.is_pr_cleanup}} IS_NOT_SOURCE_GITHUB: ${{ inputs.is_not_source_github }} GIT_USER_NAME: ${{ inputs.git_user_name }} GIT_USER_EMAIL: ${{ inputs.git_user_email }} diff --git a/src/sync_template.sh b/src/sync_template.sh index e114ef4d..cb819987 100644 --- a/src/sync_template.sh +++ b/src/sync_template.sh @@ -66,6 +66,7 @@ echo "::endgroup::" cmd_from_yml_file "prepull" echo "::group::Pull template" + debug "create new branch from default branch with name ${NEW_BRANCH}" git checkout -b "${NEW_BRANCH}" debug "pull changes from template" @@ -97,6 +98,7 @@ fi cmd_from_yml_file "precommit" echo "::group::commit changes" + git add . # we are checking the ignore file if it exists or is empty @@ -121,26 +123,96 @@ git commit -m "${PR_COMMIT_MSG}" echo "::endgroup::" -push_and_create_pr () { - cmd_from_yml_file "prepush" - if [ "$IS_DRY_RUN" != "true" ]; then +cleanup_older_prs () { + older_prs=$(gh pr list \ + --base "${UPSTREAM_BRANCH}" \ + --state open \ + --label "${PR_LABELS}" \ + --json number \ + --template '{{range .}}{{printf "%v" .number}}{{"\n"}}{{end}}') + + for older_pr in $older_prs + do + gh pr close "$older_pr" + debug "Closed PR #${older_pr}" + done +} +echo "::group::cleanup older PRs" + +if [ "$IS_DRY_RUN" != "true" ]; then + if [ "$IS_PR_CLEANUP" != "false" ]; then + if [[ -z "${PR_LABELS}" ]]; then + warn "env var 'PR_LABELS' is empty. Skipping older prs cleanup" + else + cmd_from_yml_file "precleanup" + cleanup_older_prs + fi + else + warn "is_pr_cleanup option is set to off. Skipping older prs cleanup" + fi +else + warn "dry_run option is set to off. Skipping older prs cleanup" +fi + +echo "::endgroup::" - echo "::group::push changes and create PR" - debug "push changes" - git push --set-upstream origin "${NEW_BRANCH}" - cmd_from_yml_file "prepr" +maybe_create_labels () { + all_labels=${PR_LABELS//,/$'\n'} + for label in $all_labels + do + search_result=$(gh label list \ + --search "${label}" \ + --limit 1 \ + --json name \ + --template '{{range .}}{{printf "%v" .name}}{{"\n"}}{{end}}') + + if [ "${search_result}" = "${label}" ]; then + info "label '${label}' was found in the repository" + else + gh label create "${label}" + info "label '${label}' was missing and has been created" + fi + done +} + +echo "::group::check for missing labels" - gh pr create \ - --title "${PR_TITLE}" \ - --body "Merge ${SOURCE_REPO_PATH} ${NEW_TEMPLATE_GIT_HASH}" \ - --base "${UPSTREAM_BRANCH}" \ - --label "${PR_LABELS}" \ - --reviewer "${PR_REVIEWERS}" - echo "::endgroup::" +if [[ -z "${PR_LABELS}" ]]; then + info "env var 'PR_LABELS' is empty. Skipping labels check" +else + if [ "$IS_DRY_RUN" != "true" ]; then + maybe_create_labels else - warn "dry_run option is set to off. Skipping push changes and skip create pr" + warn "dry_run option is set to off. Skipping labels check" fi +fi + +echo "::endgroup::" + +push () { + debug "push changes" + git push --set-upstream origin "${NEW_BRANCH}" +} + +create_pr () { + gh pr create \ + --title "${PR_TITLE}" \ + --body "Merge ${SOURCE_REPO_PATH} ${NEW_TEMPLATE_GIT_HASH}" \ + --base "${UPSTREAM_BRANCH}" \ + --label "${PR_LABELS}" \ + --reviewer "${PR_REVIEWERS}" } -push_and_create_pr +echo "::group::push changes and create PR" + +if [ "$IS_DRY_RUN" != "true" ]; then + cmd_from_yml_file "prepush" + push + cmd_from_yml_file "prepr" + create_pr +else + warn "dry_run option is set to off. Skipping push changes and skip create pr" +fi + +echo "::endgroup::" From c7e138cb489eea55ff7ecf2f5f2bacd1122be4bf Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 25 Jan 2024 12:04:57 +0100 Subject: [PATCH 2/7] chore(main): release 1.4.0 (#446) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ea215907..468b77c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## [1.4.0](https://github.com/AndreasAugustin/actions-template-sync/compare/v1.3.0...v1.4.0) (2024-01-25) + + +### Features + +* allow for pruning of older PRs ([#438](https://github.com/AndreasAugustin/actions-template-sync/issues/438)) ([0e51714](https://github.com/AndreasAugustin/actions-template-sync/commit/0e51714bd42e4ce8223a641d7435c220a99aad51)) + ## [1.3.0](https://github.com/AndreasAugustin/actions-template-sync/compare/v1.2.0...v1.3.0) (2024-01-18) From 9f5356d444068486db961312dd3f111ffe150d29 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 31 Jan 2024 11:58:42 +0100 Subject: [PATCH 3/7] Chore(deps): Bump alpine from 3.19.0 to 3.19.1 (#448) Bumps alpine from 3.19.0 to 3.19.1. --- updated-dependencies: - dependency-name: alpine dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 995c9077..d67eb41e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ ####################################### # image for dev build environment ###################################### -FROM alpine:3.19.0 as dev +FROM alpine:3.19.1 as dev ARG GH_CLI_VER=2.34.0 From 8da6fd38ec4e5f9a341811ce69d93800e370de53 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 31 Jan 2024 11:59:09 +0100 Subject: [PATCH 4/7] Chore(deps): Bump alpine from 3.19.0 to 3.19.1 in /src (#449) Bumps alpine from 3.19.0 to 3.19.1. --- updated-dependencies: - dependency-name: alpine dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- src/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Dockerfile b/src/Dockerfile index 826b49d0..11fee153 100644 --- a/src/Dockerfile +++ b/src/Dockerfile @@ -1,4 +1,4 @@ -FROM alpine:3.19.0 +FROM alpine:3.19.1 ARG GH_CLI_VER=2.34.0 From c94c3494be2e07c20a63ed2a2985250093b1e64d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 31 Jan 2024 11:59:39 +0100 Subject: [PATCH 5/7] Chore(deps): Bump peter-evans/dockerhub-description from 3 to 4 (#447) Bumps [peter-evans/dockerhub-description](https://github.com/peter-evans/dockerhub-description) from 3 to 4. - [Release notes](https://github.com/peter-evans/dockerhub-description/releases) - [Commits](https://github.com/peter-evans/dockerhub-description/compare/v3...v4) --- updated-dependencies: - dependency-name: peter-evans/dockerhub-description dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/push_docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push_docker.yml b/.github/workflows/push_docker.yml index bfa70b65..39ea2833 100644 --- a/.github/workflows/push_docker.yml +++ b/.github/workflows/push_docker.yml @@ -65,7 +65,7 @@ jobs: tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - name: Docker Hub Description - uses: peter-evans/dockerhub-description@v3 + uses: peter-evans/dockerhub-description@v4 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} From e68941ff0fc9695be3fe480ab739ebeb318dca0d Mon Sep 17 00:00:00 2001 From: andy Augustin Date: Sun, 4 Feb 2024 11:02:52 +0100 Subject: [PATCH 6/7] feat: :sparkles: (#401) add option to force file deletion (#435) * feat: :sparkles: (#401) add option to force file deletion * fix: :bug: (#401) * fix: :bug: (#401) * fix: :bug: (#401) fix some small issues * refactor: :recycle: enhance readability * docs: :memo: (#401) some docs addons * style: :rotating_light: lint issue --- README.md | 9 +++++++++ action.yml | 4 ++++ src/sync_common.sh | 10 +++++----- src/sync_template.sh | 30 +++++++++++++++++++++++++----- 4 files changed, 43 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 26b6a6e9..34ae1aeb 100644 --- a/README.md +++ b/README.md @@ -248,6 +248,7 @@ jobs: | is_allow_hooks | `[optional]` set to `true` if you want to enable lifecycle hooks. Use this with caution! | `false` | `false` | | is_pr_cleanup | `[optional]` set to `true` if you want to cleanup older PRs targeting the same branch. Use this with caution! | `false` | `false` | | is_not_source_github | `[optional]` set to `true` if the source git provider is not GitHub | `false` | `false` | +| is_force_deletion | `[optional]` set to `true` if you want to force delete files which are deleted within the source repository even if they contain changes. You need to also adjust `git_remote_pull_params` (see below for details) | `false` | `false` | | git_user_name | `[optional]` set the committer git user.name | `false` | `${GITHUB_ACTOR}` | | git_user_email | `[optional]` set the committer git user.email | `false` | `github-action@actions-template-sync.noreply.${SOURCE_REPO_HOSTNAME}` | | git_remote_pull_params | `[optional]` set remote pull parameters | `false` | `--allow-unrelated-histories --squash --strategy=recursive -X theirs` | @@ -351,8 +352,16 @@ Associating a label with the generated PRs helps keeping track of them and allow Depending on your way of working, you may end up with multiple pull requests related to template syncing pointing to the same branch. If you want to avoid this situation, you can instruct this action to clean up older PRs (search based on labels defined with the `pr_labels` config parameter). + :warning: this feature will close all pull requests with labels configured with `pr_labels` config parameter. +## Force deletion + +This feature will force delete files if those are deelted within the source repository. + +:warning: it is highly related to the `git_remote_pull_params` config parameter and won't work with the default. +You need to change the default one e.g. to `git_remote_pull_params: --allow-unrelated-histories --strategy=recursive --no-edit`. + ## Troubleshooting * refusing to allow a GitHub App to create or update workflow `.github/workflows/******.yml` without `workflows` permission diff --git a/action.yml b/action.yml index 760b5786..f3f654d1 100644 --- a/action.yml +++ b/action.yml @@ -43,6 +43,9 @@ inputs: is_not_source_github: description: "[optional] set to true if the source repository is not a github related repository. Useful e.q. if the source is GitLab" default: "false" + is_force_deletion: + description: "[optional] set to true if you want to force delete files which are deleted within the source repository even if they contain changes" + default: "false" git_user_name: description: "[optional] set the committer git user.name for the merge commit" git_user_email: @@ -67,6 +70,7 @@ runs: IS_ALLOW_HOOKS: ${{ inputs.is_allow_hooks }} IS_PR_CLEANUP: ${{ inputs.is_pr_cleanup}} IS_NOT_SOURCE_GITHUB: ${{ inputs.is_not_source_github }} + IS_FORCE_DELETION: ${{ inputs.is_force_deletion }} GIT_USER_NAME: ${{ inputs.git_user_name }} GIT_USER_EMAIL: ${{ inputs.git_user_email }} GIT_REMOTE_PULL_PARAMS: ${{ inputs.git_remote_pull_params }} diff --git a/src/sync_common.sh b/src/sync_common.sh index 36acaf43..8677a408 100755 --- a/src/sync_common.sh +++ b/src/sync_common.sh @@ -9,7 +9,7 @@ set -e # Arguments: # message to print. ####################################### -err() { +function err() { echo "::error::[$(date +'%Y-%m-%dT%H:%M:%S%z')]: $*" >&2; } @@ -18,7 +18,7 @@ err() { # Arguments: # message to print. ####################################### -debug() { +function debug() { echo "::debug::$*"; } @@ -27,7 +27,7 @@ debug() { # Arguments: # message to print. ####################################### -warn() { +function warn() { echo "::warn::$*"; } @@ -36,7 +36,7 @@ warn() { # Arguments: # message to print. ####################################### -info() { +function info() { echo "::info::$*"; } @@ -46,7 +46,7 @@ info() { # hook -> the hook to use # ####################################3# -cmd_from_yml_file() { +function cmd_from_yml_file() { local FILE_NAME="templatesync.yml" local HOOK=$1 local YML_PATH=".hooks.${HOOK}.commands" diff --git a/src/sync_template.sh b/src/sync_template.sh index cb819987..7894a55c 100644 --- a/src/sync_template.sh +++ b/src/sync_template.sh @@ -36,6 +36,10 @@ GIT_REMOTE_PULL_PARAMS="${GIT_REMOTE_PULL_PARAMS:---allow-unrelated-histories -- cmd_from_yml_file "install" +LOCAL_CURRENT_GIT_HASH=$(git rev-parse HEAD) + +info "current git hash: ${LOCAL_CURRENT_GIT_HASH}" + TEMPLATE_SYNC_IGNORE_FILE_PATH=".templatesyncignore" TEMPLATE_REMOTE_GIT_HASH=$(git ls-remote "${SOURCE_REPO}" HEAD | awk '{print $1}') NEW_TEMPLATE_GIT_HASH=$(git rev-parse --short "${TEMPLATE_REMOTE_GIT_HASH}") @@ -44,7 +48,7 @@ debug "new Git HASH ${NEW_TEMPLATE_GIT_HASH}" echo "::group::Check new changes" -check_branch_remote_existing() { +function check_branch_remote_existing() { git ls-remote --exit-code --heads origin "${NEW_BRANCH}" || BRANCH_DOES_NOT_EXIST=true if [[ "${BRANCH_DOES_NOT_EXIST}" != true ]]; then @@ -95,6 +99,22 @@ if [ -s "${TEMPLATE_SYNC_IGNORE_FILE_PATH}" ]; then echo "::endgroup::" fi +function force_delete_files() { + echo "::group::force file deletion" + warn "force file deletion is enabled. Deleting files which are deleted within the target repository" + FILES_TO_DELETE=$(git log --diff-filter D --pretty="format:" --name-only "${LOCAL_CURRENT_GIT_HASH}"..HEAD | sed '/^$/d') + warn "files to delete: ${FILES_TO_DELETE}" + if [[ -n "${FILES_TO_DELETE}" ]]; then + echo "${FILES_TO_DELETE}" | xargs rm + fi + + echo "::endgroup::" +} + +if [ "$IS_FORCE_DELETION" == "true" ]; then + force_delete_files +fi + cmd_from_yml_file "precommit" echo "::group::commit changes" @@ -123,7 +143,7 @@ git commit -m "${PR_COMMIT_MSG}" echo "::endgroup::" -cleanup_older_prs () { +function cleanup_older_prs () { older_prs=$(gh pr list \ --base "${UPSTREAM_BRANCH}" \ --state open \ @@ -157,7 +177,7 @@ fi echo "::endgroup::" -maybe_create_labels () { +function maybe_create_labels () { all_labels=${PR_LABELS//,/$'\n'} for label in $all_labels do @@ -190,12 +210,12 @@ fi echo "::endgroup::" -push () { +function push () { debug "push changes" git push --set-upstream origin "${NEW_BRANCH}" } -create_pr () { +function create_pr () { gh pr create \ --title "${PR_TITLE}" \ --body "Merge ${SOURCE_REPO_PATH} ${NEW_TEMPLATE_GIT_HASH}" \ From 33f86ba0dbd01d559b5ce5d28482148622555b11 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 4 Feb 2024 11:11:41 +0100 Subject: [PATCH 7/7] chore(main): release 1.5.0 (#452) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 468b77c8..e9c04d0f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## [1.5.0](https://github.com/AndreasAugustin/actions-template-sync/compare/v1.4.0...v1.5.0) (2024-02-04) + + +### Features + +* :sparkles: ([#401](https://github.com/AndreasAugustin/actions-template-sync/issues/401)) add option to force file deletion ([#435](https://github.com/AndreasAugustin/actions-template-sync/issues/435)) ([e68941f](https://github.com/AndreasAugustin/actions-template-sync/commit/e68941ff0fc9695be3fe480ab739ebeb318dca0d)) + ## [1.4.0](https://github.com/AndreasAugustin/actions-template-sync/compare/v1.3.0...v1.4.0) (2024-01-25)