Skip to content

Commit

Permalink
fix Build and Push Tag github action bugs
Browse files Browse the repository at this point in the history
  • 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.
30 changes: 21 additions & 9 deletions .github/workflows/build_and_push_python_codes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
uses: actions/checkout@v2
with:
ref: ${{ github.ref }}
fetch-depth: 0

- name: Install dependencies
run: |
Expand All @@ -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 }}

0 comments on commit 742c312

Please sign in to comment.