Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
Signed-off-by: Jonathan Østrup <[email protected]>
  • Loading branch information
TechnicallyJoe authored Oct 15, 2024
2 parents 3ce6773 + 2e7777b commit 6d0f519
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 11 deletions.
9 changes: 4 additions & 5 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
---
#-------------------------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
#-------------------------------------------------------------------------------------------------------------

version: '3.7'
services:
# Update this to the name of the service you want to work with in your docker-compose.yml file
dev:
# You may want to add a non-root user to your Dockerfile and uncomment the line below
# to cause all processes to run as this user. Once present, you can also simply
# use the "remoteUser" property in devcontainer.json if you just want VS Code and
# its sub-processes (terminals, tasks, debugging) to execute as the user. On Linux,
# you may need to ensure the UID and GID of the container user you create matches your
# you may need to ensure the UID and GID of the container user you create matches your
# local user. See https://aka.ms/vscode-remote/containers/non-root for details.
# user: vscode

Expand All @@ -23,13 +23,13 @@ services:
# Uncomment if you want to expose any additional ports. The snippet below exposes port 3000.
# ports:
# - 3000:3000

volumes:
# Update this to wherever you want VS Code to mount the folder of your project
- .:/workspace:cached

# Uncomment the next line to use Docker from inside the container. See https://aka.ms/vscode-remote/samples/docker-in-docker-compose for details.
# - /var/run/docker.sock:/var/run/docker.sock
# - /var/run/docker.sock:/var/run/docker.sock

# Uncomment the next four lines if you will use a ptrace-based debugger like C++, Go, and Rust.
# cap_add:
Expand All @@ -39,4 +39,3 @@ services:

# Overrides default command so things don't shut down after the process ends.
command: /bin/sh -c "while sleep 1000; do :; done"

7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## [2.3.0](https://github.com/AndreasAugustin/actions-template-sync/compare/v2.2.3...v2.3.0) (2024-10-14)


### Features

* **#547:** :sparkles: add option to include git tags ([#561](https://github.com/AndreasAugustin/actions-template-sync/issues/561)) ([01f7623](https://github.com/AndreasAugustin/actions-template-sync/commit/01f7623dbfc8f73ccaf1635d64cb629a699acc9a))

## [2.2.3](https://github.com/AndreasAugustin/actions-template-sync/compare/v2.2.2...v2.2.3) (2024-06-19)


Expand Down
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ jobs:
| gpg_passphrase | `[optional]` set if your optionial gpg private key has a passphrase | `false` | |
| steps | `[optional] add the steps you want to execute within the action` | `false` | all steps will be executed |
| template_sync_ignore_file_path | `[optional] set the path to the ignore file.` | false |`.templatesyncignore` |
| is_with_tags | `[optional]` set to `true` if tags should be synced | `false` | `false` |

### Action Outputs

Expand Down Expand Up @@ -574,6 +575,30 @@ This feature will force delete files if those are deelted within the source repo
: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`.

## GHES and custom runners

Some notes if you use GitHub Enterprise Server (GHES) and/or custom runners.
The action script is based on bash. That means your runner must be able to run bash scripts.
Furthermore you need to have the following command line tools installed:

* ssh
* [GitHub cli][gh-cli]
* git
* optional (dependent the features you are using)
* [git lfs][git-lfs] if you are using the lfs functionality
* [yq][yq] if you are using the hook functionality
* gpg if you are using the git signing functionality

Furthermore most likely you have a custom domain name. Therefore you should configure the `hostname` GitHub action parameter.

### Remark

:whale: There is also a docker image available which has all needed tools installed. This is helpful e.g. if you are not able to use a remote action.
The idea is to use the [docker action][action-docker]

* [GitHub registry][github-repo]
* [Dockerhub registry][dockerhub-repo]

## Troubleshooting

* refusing to allow a GitHub App to create or update workflow `.github/workflows/******.yml` without `workflows` permission
Expand Down Expand Up @@ -767,3 +792,6 @@ specification. Contributions of any kind are welcome!
[github-create-secret]: https://docs.github.com/en/actions/security-guides/using-secrets-in-github-actions#creating-secrets-for-a-repository
[github-create-gpg-key]: https://docs.github.com/en/authentication/managing-commit-signature-verification/generating-a-new-gpg-key
[github-gh-cli-pr-edit]: https://cli.github.com/manual/gh_pr_edit
[gh-cli]: https://github.com/cli/cli
[yq]: https://github.com/mikefarah/yq
[git-lfs]: https://github.com/git-lfs/git-lfs
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ inputs:
template_sync_ignore_file_path:
description: "[optional] set the path to the ignore file"
default: ".templatesyncignore"
is_with_tags:
description: "[optional] set to true if tags should be synced"
default: "false"
outputs:
pr_branch:
description: "The name of the PR branch"
Expand Down Expand Up @@ -119,3 +122,4 @@ runs:
GPG_PASSPHRASE: ${{ inputs.gpg_passphrase }}
STEPS: ${{ inputs.steps }}
TEMPLATE_SYNC_IGNORE_FILE_PATH: ${{ inputs.template_sync_ignore_file_path }}
IS_WITH_TAGS: ${{ inputs.is_with_tags }}
21 changes: 15 additions & 6 deletions src/sync_template.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ if [[ -n "${SRC_SSH_PRIVATEKEY_ABS_PATH}" ]]; then
fi

TEMPLATE_SYNC_IGNORE_FILE_PATH="${TEMPLATE_SYNC_IGNORE_FILE_PATH:-".templatesyncignore"}"
IS_WITH_TAGS="${IS_WITH_TAGS:-"false"}"
IS_FORCE_PUSH_PR="${IS_FORCE_PUSH_PR:-"false"}"
IS_KEEP_BRANCH_ON_PR_CLEANUP="${IS_KEEP_BRANCH_ON_PR_CLEANUP:-"false"}"
GIT_REMOTE_PULL_PARAMS="${GIT_REMOTE_PULL_PARAMS:---allow-unrelated-histories --squash --strategy=recursive -X theirs}"
Expand Down Expand Up @@ -146,7 +147,6 @@ function check_if_commit_already_in_hist_graceful_exit() {
warn "repository is up to date!"
exit 0
fi

}

##########################################
Expand Down Expand Up @@ -236,7 +236,7 @@ function pull_source_changes() {
local source_repo=$1
local git_remote_pull_params=$2

eval "git pull ${source_repo} ${git_remote_pull_params}" || pull_has_issues=true
eval "git pull ${source_repo} --tags ${git_remote_pull_params}" || pull_has_issues=true

if [ "$pull_has_issues" == true ] ; then
warn "There had been some git pull issues."
Expand Down Expand Up @@ -285,18 +285,27 @@ function eventual_create_labels () {
# Arguments:
# branch
# is_force
# is_with_tags
##############################
function push () {
info "push changes"
local branch=$1
local is_force=$2
local is_with_tags=$3

local additional_params=" "

if [ "$is_force" == true ] ; then
warn "forcing the push."
git push --force --set-upstream origin "${branch}"
else
git push --set-upstream origin "${branch}"
additional_params="${additional_params}--force "
fi

if [ "$is_with_tags" == true ] ; then
warn "include tags."
additional_params="${additional_params}--tags "
fi

git push "${additional_params}"--set-upstream origin "${branch}"
}

####################################
Expand Down Expand Up @@ -461,7 +470,7 @@ function arr_push() {
return 0
fi
cmd_from_yml "prepush"
push "${PR_BRANCH}" "${IS_FORCE_PUSH_PR}"
push "${PR_BRANCH}" "${IS_FORCE_PUSH_PR}" "${IS_WITH_TAGS}"
echo "::endgroup::"
}

Expand Down

0 comments on commit 6d0f519

Please sign in to comment.