Skip to content

Commit fd3b932

Browse files
authored
Merge pull request #204 from MekDrop/fix/old-wiki-updating
Fix old wiki updating
2 parents 4bf8cb7 + 3d6359f commit fd3b932

File tree

5 files changed

+59
-24
lines changed

5 files changed

+59
-24
lines changed

action.yml

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,24 @@ runs:
6161
shell: bash
6262
if: inputs.setup_php == 'true'
6363

64-
- name: Checkouting original wiki with needed branch...
64+
- name: Cloning original wiki...
6565
run: |
66-
bash ${{ github.action_path }}/bin/checkout.sh \
66+
bash ${{ github.action_path }}/bin/cloning.sh \
6767
"${{ inputs.wiki_github_update_token }}" \
6868
"${{ inputs.wiki_github_update_user }}"
6969
shell: bash
7070

71+
- name: Configuring GIT...
72+
run: |
73+
bash ${{ github.action_path }}/bin/configure_git.sh \
74+
"${{ inputs.wiki_github_update_user }}" \
75+
"${{ inputs.wiki_github_update_user }}@users.noreply.github.com"
76+
shell: bash
77+
78+
- name: Checkouting needed branch...
79+
run: bash ${{ github.action_path }}/bin/checkout.sh
80+
shell: bash
81+
7182
- name: Generating new documentation with clean/phpdoc-md...
7283
uses: impresscms-dev/generate-phpdocs-with-clean-phpdoc-md-action@v0.1.6
7384
with:
@@ -107,9 +118,7 @@ runs:
107118
- name: Commit and push wiki changes...
108119
run: |
109120
bash ${{ github.action_path }}/bin/commit_and_push.sh \
110-
"${{ github.event.commits[0].message }}" \
111-
"${{ inputs.wiki_github_update_user }}" \
112-
"${{ inputs.wiki_github_update_user }}@users.noreply.github.com"
121+
"${{ github.event.commits[0].message }}"
113122
shell: bash
114123

115124
- name: Clearing temp paths...

bin/checkout.sh

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
#!/usr/bin/env bash
22

3-
PRIVATE_TOKEN="$1"
4-
GITHUB_USER="$2"
5-
6-
# shellcheck disable=SC2086
7-
git clone -q https://$GITHUB_USER:$PRIVATE_TOKEN@github.com/$GITHUB_REPOSITORY.wiki.git "$OLD_WIKI_CHECKOUT_PATH"
8-
93
# shellcheck disable=SC2164
104
pushd "$OLD_WIKI_CHECKOUT_PATH"
115

12-
if git show-ref -q --heads "$GITHUB_REF_NAME"; then
6+
git ls-remote -q --heads --exit-code origin "$GITHUB_REF_NAME" > /dev/null
7+
REMOTE_CHECK_EXIT_CODE=$?
8+
9+
git show-ref -q --heads "$GITHUB_REF_NAME" > /dev/null
10+
LOCAL_CHECK_EXIT_CODE=$?
11+
12+
if [ "$REMOTE_CHECK_EXIT_CODE" -gt 0 ] || [ "$LOCAL_CHECK_EXIT_CODE" -gt 0 ]; then
13+
echo "Remote '$GITHUB_REF_NAME' found."
1314
git checkout "$GITHUB_REF_NAME"
1415
else
16+
echo "Remote '$GITHUB_REF_NAME' not found. Creating."
1517
git checkout -b "$GITHUB_REF_NAME"
18+
git push --set-upstream origin "$GITHUB_REF_NAME"
1619
fi;
1720

18-
git branch --set-upstream-to=origin/$GITHUB_REF_NAME "$GITHUB_REF_NAME"
19-
2021
# shellcheck disable=SC2164
2122
popd

bin/cloning.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env bash
2+
3+
PRIVATE_TOKEN="$1"
4+
GITHUB_USER="$2"
5+
6+
# shellcheck disable=SC2086
7+
git clone -q https://$GITHUB_USER:$PRIVATE_TOKEN@github.com/$GITHUB_REPOSITORY.wiki.git "$OLD_WIKI_CHECKOUT_PATH"
8+
9+
if [ ! -d "$OLD_WIKI_CHECKOUT_PATH" ]; then
10+
echo "ERROR: wiki directory not created. Perhaps You didn't created at least one web page?"
11+
exit 1
12+
fi

bin/commit_and_push.sh

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,19 @@ COMMITER_EMAIL="$3"
77
# shellcheck disable=SC2164
88
pushd "$NEW_WIKI_CHECKOUT_PATH"
99

10-
echo "Configuring GIT..."
11-
git config user.email "$COMMITER_EMAIL" || exit 1
12-
git config user.name "$COMMITER_NAME" || exit 2
13-
git config advice.addEmptyPathspec false
14-
git config pull.rebase false
15-
git config advice.skippedCherryPicks false
16-
git config advice.setUpstreamFailure false
10+
git branch -a
1711

1812
echo "Adding changes to GIT..."
1913
git add -A --verbose
2014

21-
echo "Commiting..."
15+
echo "Committing..."
2216
git commit -m "$COMMIT_MESSAGE"
2317

2418
echo "Pulling and merging from remote..."
25-
git branch --set-upstream-to=origin/$GITHUB_REF_NAME "$GITHUB_REF_NAME" || true
2619
git pull -s recursive -X ours || true
2720

2821
echo "Pushing to remote..."
29-
git push --set-upstream origin "$GITHUB_REF_NAME" || exit 3
22+
git push || exit 1
3023

3124
# shellcheck disable=SC2164
3225
popd

bin/configure_git.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
COMMITER_NAME="$1"
2+
COMMITER_EMAIL="$2"
3+
4+
# shellcheck disable=SC2164
5+
pushd "$OLD_WIKI_CHECKOUT_PATH"
6+
7+
if [ "$COMMITER_NAME" == "" ]; then
8+
echo "ERROR: 'wiki_github_update_user' not set"
9+
exit 3
10+
fi;
11+
12+
git config user.email "$COMMITER_EMAIL" || exit 1
13+
git config user.name "$COMMITER_NAME" || exit 2
14+
git config advice.addEmptyPathspec false
15+
git config pull.rebase false
16+
git config advice.skippedCherryPicks false
17+
git config advice.setUpstreamFailure false
18+
19+
# shellcheck disable=SC2164
20+
popd

0 commit comments

Comments
 (0)