Skip to content

Commit 407e695

Browse files
MmahdiM79Mohammad Mahdi Malmasi
authored and
Mohammad Mahdi Malmasi
committed
fix Build and Push Tag github action bugs (#61)
1 parent 920bd5f commit 407e695

File tree

1 file changed

+23
-9
lines changed

1 file changed

+23
-9
lines changed

.github/workflows/build_and_push_python_codes.yml

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ jobs:
2121
uses: actions/checkout@v2
2222
with:
2323
ref: ${{ github.ref }}
24+
fetch-depth: 0
2425

2526
- name: Install dependencies
2627
run: |
@@ -46,16 +47,29 @@ jobs:
4647
4748
- name: Commit changes
4849
run: |
49-
bash -c "if [[ ${{ github.ref }} == 'refs/tags/'* ]]; then export TAG_NAME=${{ github.ref }}; fi"
50-
echo "Tag name: $TAG_NAME"
51-
echo "payload: ${{ github.event.client_payload.tag_name }}"
50+
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
51+
TAG_NAME="${GITHUB_REF#refs/tags/}"
52+
echo "Tag name: $TAG_NAME"
53+
echo "payload: ${{ github.event.client_payload.tag_name }}"
54+
echo "TAG_NAME=$TAG_NAME" >> $GITHUB_ENV
55+
fi
56+
LAST_COMMIT_MESSAGE=$(git log -1 --pretty=format:'%s')
5257
cd destination-repo
53-
git config user.email "[email protected]"
54-
git config user.name "Mohammad Mahdi Malmasi"
58+
LAST_GIT_COMMIT_NAME=$(git log -1 --pretty=format:'%an')
59+
LAST_GIT_COMMIT_EMAIL=$(git log -1 --pretty=format:'%ae')
60+
git config user.name "$LAST_GIT_COMMIT_NAME"
61+
git config user.email "$LAST_GIT_COMMIT_EMAIL"
5562
git add .
56-
git commit -m "Update for tag: $TAG_NAME"
57-
git tag $TAG_NAME
58-
git push --tags
59-
git push origin master
63+
echo "git tag to be pushed: '$TAG_NAME'"
64+
if [ -z "$(git status --porcelain)" ]; then
65+
echo "No changes to commit. push only new tag."
66+
git tag $TAG_NAME
67+
git push --tags
68+
else
69+
git commit -m "$TAG_NAME | $LAST_COMMIT_MESSAGE"
70+
git tag "$TAG_NAME"
71+
git push --tags
72+
git push origin master
73+
fi
6074
env:
6175
TAG_NAME: ${{ github.event.client_payload.tag_name }}

0 commit comments

Comments
 (0)