Skip to content

Commit

Permalink
Skipping release if no changes
Browse files Browse the repository at this point in the history
  • Loading branch information
aasimkhan30 committed Aug 10, 2024
1 parent c7a9ced commit e85bd7f
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: CI
name: CS
on:
schedule:
- cron: '0 0 * * *'
Expand All @@ -15,7 +15,7 @@ permissions:
packages: write

jobs:
build-and-test:
create_release:
runs-on: ubuntu-latest

steps:
Expand Down Expand Up @@ -67,11 +67,21 @@ jobs:
git config --global user.name "github-actions[bot]"
cd ./release
git add .
git commit -m "Release v${{ env.version }}"
echo "Pushing with message: Release v${{ env.version }}"
git push origin release
CHANGED_FILES=$(git diff-index --quiet HEAD)
if [ -n "$CHANGED_FILES" ]; then
echo "Pushing with message: Release v${{ env.version }}"
git commit -m "Release v${{ env.version }}"
echo "Pushing with message: Release v${{ env.version }}"
git push origin release
echo "skip_release=false" >> $GITHUB_ENV
else
echo "No changes to push"
echo "skip_release=true" >> $GITHUB_ENV
fi
- name: Generate release notes
if: skip_release == 'false'
run: |
cd ./release
PREV_TAG=$(git describe --tags --abbrev=0)
Expand All @@ -82,14 +92,14 @@ jobs:
echo "EOF" >> $GITHUB_ENV
- name: Printing release notes
if: always()
if: skip_release == 'false'
run: |
echo " ${{ env.RELEASE_NOTES }} "
echo v${{ env.version }}
echo ${{ env.exists }}
- name: Create Release
if: env.exists == 'false'
if: env.exists == 'false' && skip_release == 'false'
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down

0 comments on commit e85bd7f

Please sign in to comment.