fix github actions#4
Conversation
There was a problem hiding this comment.
Pull request overview
This PR attempts to fix GitHub Actions by enabling the workflow to commit build artifacts (ZIP files) back to the repository. The changes include adding permissions for the workflow to write to the repository, configuring git to push commits, and removing ZIP files from .gitignore so they can be tracked.
Key changes:
- Added
contents: writepermission to the GitHub Actions workflow - Implemented automatic commit and push of built ZIP files to the main branch
- Removed
releases/*.zipfrom.gitignoreto allow tracking of build artifacts
Reviewed changes
Copilot reviewed 1 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
.github/workflows/build-and-release.yml |
Added permissions and a new step to commit and push ZIP files back to the main branch after builds |
.gitignore |
Removed exclusion for releases/*.zip to allow committing build artifacts |
releases/accordion-hero-slider-v1.1.0.zip |
Added binary build artifact to the repository |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| - name: Commit and Push ZIP (Main Branch only) | ||
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | ||
| run: | | ||
| git config --local user.email "action@github.com" | ||
| git config --local user.name "GitHub Action" | ||
| git add releases/*.zip | ||
| git commit -m "chore: build version v${{ env.VERSION }} [skip ci]" || echo "No changes to commit" | ||
| git push origin main | ||
|
|
There was a problem hiding this comment.
The commit step will create an infinite loop because while it includes "[skip ci]" in the commit message, the workflow is triggered on pushes to main. Even with "[skip ci]", some CI systems may still trigger. Additionally, this creates a race condition if multiple PRs are merged simultaneously - each will try to push to main which could cause conflicts.
Consider using a bot account with specific permissions or restructure the workflow to avoid committing back to the repository during the build process. A better approach would be to only commit the ZIP file during tagged releases or use GitHub Releases to store artifacts without committing them to the repository.
| - name: Commit and Push ZIP (Main Branch only) | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| run: | | |
| git config --local user.email "action@github.com" | |
| git config --local user.name "GitHub Action" | |
| git add releases/*.zip | |
| git commit -m "chore: build version v${{ env.VERSION }} [skip ci]" || echo "No changes to commit" | |
| git push origin main |
| - name: Commit and Push ZIP (Main Branch only) | ||
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | ||
| run: | | ||
| git config --local user.email "action@github.com" |
There was a problem hiding this comment.
Using "action@github.com" as the commit email is not following GitHub's recommended practice. GitHub recommends using the noreply email format for GitHub Actions: "{github_actor_id}+{github_actor}@users.noreply.github.com" or "github-actions[bot]@users.noreply.github.com". This ensures proper attribution in the commit history.
| git config --local user.email "action@github.com" | |
| git config --local user.email "github-actions[bot]@users.noreply.github.com" |
No description provided.