Skip to content

Commit

Permalink
update: show verbose log while execute script
Browse files Browse the repository at this point in the history
  • Loading branch information
k8scat committed Jan 6, 2022
1 parent 60c259f commit 02b7281
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
echo "::set-output name=repo_list::${repo_list}"
- name: action-git-mirror
uses: k8scat/[email protected].23
uses: k8scat/[email protected].24
with:
source_protocol: https
source_host: github.com
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
os = $(shell uname -s)

version = 0.0.23
version = 0.0.24
image = mirror-git:$(version)

cr_user = gigrator
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ docker run \
-e INPUT_FORCE_PUSH="false" \
-e INPUT_NOTIFY_PREFIX="Mirror Git" \
-e INPUT_NOTIFY_SUFFIX="Powered by https://github.com/k8scat/action-mirror-git" \
gigrator/mirror-git:0.0.23
gigrator/mirror-git:0.0.24
```

## LICENSE
Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,4 @@ inputs:
default: "false"
runs:
using: "docker"
image: "docker://ghcr.io/k8scat/mirror-git:0.0.23"
image: "docker://ghcr.io/k8scat/mirror-git:0.0.24"
31 changes: 29 additions & 2 deletions mirror.sh
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,13 @@ function mirror() {
fi

if [[ -n "${INPUT_DEST_CREATE_REPO_SCRIPT}" ]]; then
echo "Creating repo: ${REPO_NAME}"
set -x
if ! create_repo; then
notify "Failed to create repo: ${REPO_NAME}"
return 1
fi
set +x
fi

repo_dir="${WORKDIR}/${REPO_NAME}"
Expand All @@ -213,12 +216,24 @@ function mirror() {
if ! git push --all -f "${dest_addr}"; then
notify "Failed to push ${REPO_NAME} to ${dest_addr} with --all flag"
if [[ "${INPUT_FORCE_PUSH}" = "true" && -n "${INPUT_DEST_DELETE_REPO_SCRIPT}" && -n "${INPUT_DEST_CREATE_REPO_SCRIPT}" ]]; then
echo "Deleting repo: ${REPO_NAME}"
set -x
if ! delete_repo; then
notify "Failed to delete repo: ${REPO_NAME}"
return 1
fi
create_repo || return 1
set +x

echo "Creating repo: ${REPO_NAME}"
set -x
if ! create_repo; then
notify "Failed to create repo: ${REPO_NAME}"
return 1
fi
set +x

if ! git push --all -f "${dest_addr}"; then
notify "Still failed to push ${REPO_NAME} to ${dest_addr} with --all flag"
return 1
fi
fi
Expand All @@ -227,12 +242,24 @@ function mirror() {
if ! git push --mirror -f "${dest_addr}"; then
notify "Failed to push ${REPO_NAME} to ${dest_addr} with --mirror flag"
if [[ "${INPUT_FORCE_PUSH}" = "true" && -n "${INPUT_DEST_DELETE_REPO_SCRIPT}" && -n "${INPUT_DEST_CREATE_REPO_SCRIPT}" ]]; then
echo "Deleting repo: ${REPO_NAME}"
set -x
if ! delete_repo; then
notify "Failed to delete repo: ${REPO_NAME}"
return 1
fi
create_repo || return 1
set +x

echo "Creating repo: ${REPO_NAME}"
set -x
if ! create_repo; then
notify "Failed to create repo: ${REPO_NAME}"
return 1
fi
set +x

if ! git push --mirror -f "${dest_addr}"; then
notify "Still failed to push ${REPO_NAME} to ${dest_addr} with --mirror flag"
return 1
fi
fi
Expand Down

0 comments on commit 02b7281

Please sign in to comment.