Skip to content

Commit

Permalink
feat(#547): ✨ add option to include git tags (#561)
Browse files Browse the repository at this point in the history
Signed-off-by: Andy Augustin <[email protected]>
  • Loading branch information
AndreasAugustin authored Oct 14, 2024
1 parent db54a8f commit 01f7623
Show file tree
Hide file tree
Showing 4 changed files with 24 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"

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ jobs:
| gpg_private_key | `[optional]` set if you want to sign commits | `false` | |
| 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 |
| is_with_tags | `[optional]` set to `true` if tags should be synced | `false` | `false` |

### Action Outputs

Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ inputs:
description: "[optional] set if your private gpg key has a password"
steps:
description: "[optional] set the steps to execute within the action"
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 @@ -115,3 +118,4 @@ runs:
GPG_PRIVATE_KEY: ${{ inputs.gpg_private_key }}
GPG_PASSPHRASE: ${{ inputs.gpg_passphrase }}
STEPS: ${{ inputs.steps }}
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 @@ -42,6 +42,7 @@ if [[ -n "${SRC_SSH_PRIVATEKEY_ABS_PATH}" ]]; then
export GIT_SSH_COMMAND="ssh -i ${SRC_SSH_PRIVATEKEY_ABS_PATH}"
fi

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 @@ -141,7 +142,6 @@ function check_if_commit_already_in_hist_graceful_exit() {
warn "repository is up to date!"
exit 0
fi

}

##########################################
Expand Down Expand Up @@ -231,7 +231,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 @@ -280,18 +280,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 @@ -456,7 +465,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 01f7623

Please sign in to comment.