diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 81dc22964..ee566dd43 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -22,12 +22,15 @@ jobs: Flutter-Codebase-Check: name: Checking codebase runs-on: ubuntu-latest + permissions: + contents: write #needs: PR-Greeting steps: - uses: actions/checkout@v4 with: # ref: ${{ github.event.pull_request.head.sha }} fetch-depth: 0 + token: ${{ secrets.GITHUB_TOKEN }} - uses: actions/setup-java@v4 with: distribution: 'zulu' # See 'Supported distributions' for available options @@ -43,6 +46,23 @@ jobs: run: cd talawa_lint && flutter pub get && cd .. - name: Running pub get to fetch dependencies run: flutter pub get + - name: Check and commit pubspec.lock changes + env: + HEAD_REF: ${{ github.head_ref }} + run: | + if [[ $(git status --porcelain pubspec.lock) ]]; then + echo "Changes detected in pubspec.lock. Auto-committing updates." + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + git add pubspec.lock + git commit -a -m "chore: Auto-update pubspec.lock in PR #${{ github.event.pull_request.number }}" + if ! git push origin HEAD:"$HEAD_REF"; then + echo "Failed to push changes. Please check if you have the correct permissions." + exit 1 + fi + else + echo "No changes in pubspec.lock." + fi - name: Checking for correct formatting of code run: dart format --set-exit-if-changed . - name: Count lines of code in each file @@ -58,7 +78,6 @@ jobs: git branch git checkout -b temp_branch git branch - git stash push -m lock_file pubspec.lock git checkout develop-postgres git pull git branch