-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix Build and Push Tag github action bugs
- Loading branch information
Mohammad Mahdi Malmasi
committed
Apr 19, 2024
1 parent
920bd5f
commit 742c312
Showing
1 changed file
with
21 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ jobs: | |
uses: actions/checkout@v2 | ||
with: | ||
ref: ${{ github.ref }} | ||
fetch-depth: 0 | ||
|
||
- name: Install dependencies | ||
run: | | ||
|
@@ -46,16 +47,27 @@ jobs: | |
- name: Commit changes | ||
run: | | ||
bash -c "if [[ ${{ github.ref }} == 'refs/tags/'* ]]; then export TAG_NAME=${{ github.ref }}; fi" | ||
echo "Tag name: $TAG_NAME" | ||
echo "payload: ${{ github.event.client_payload.tag_name }}" | ||
if [[ "${{ github.ref }}" == refs/tags/* ]]; then | ||
TAG_NAME="${GITHUB_REF#refs/tags/}" | ||
echo "Tag name: $TAG_NAME" | ||
echo "payload: ${{ github.event.client_payload.tag_name }}" | ||
echo "TAG_NAME=$TAG_NAME" >> $GITHUB_ENV | ||
fi | ||
LAST_COMMIT_MESSAGE=$(git log -1 --pretty=format:'%s') | ||
cd destination-repo | ||
git config user.email "[email protected]" | ||
git config user.name "Mohammad Mahdi Malmasi" | ||
LAST_GIT_COMMIT_NAME=$(git log -1 --pretty=format:'%an') | ||
LAST_GIT_COMMIT_EMAIL=$(git log -1 --pretty=format:'%ae') | ||
git config user.name "$LAST_GIT_COMMIT_NAME" | ||
git config user.email "$LAST_GIT_COMMIT_EMAIL" | ||
git add . | ||
git commit -m "Update for tag: $TAG_NAME" | ||
git tag $TAG_NAME | ||
git push --tags | ||
git push origin master | ||
if [ -z "$(git status --porcelain)" ]; then | ||
echo "No changes to commit. push only new tag." | ||
git tag $TAG_NAME | ||
git push --follow-tags | ||
else | ||
git commit -m "$TAG_NAME | $LAST_COMMIT_MESSAGE" | ||
git tag "$TAG_NAME" | ||
git push --follow-tags | ||
git push origin master | ||
env: | ||
TAG_NAME: ${{ github.event.client_payload.tag_name }} |