-
Notifications
You must be signed in to change notification settings - Fork 18
feat(ci): update workflow to build and push Docker image to GHCR #351
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughA new job called Changes
Sequence Diagram(s)sequenceDiagram
participant GitHub Actions
participant GitHub Container Registry
GitHub Actions->>GitHub Actions: Wait for 'coverage' job
GitHub Actions->>GitHub Actions: Checkout repository code
GitHub Actions->>GitHub Container Registry: Login using GitHub actor and token
GitHub Actions->>GitHub Actions: Set up Docker Buildx
GitHub Actions->>GitHub Container Registry: Build and push Docker image (tags: latest, main, SHA)
Possibly related issues
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
Coverage summary from CodacySee diff coverage on Codacy
Coverage variation details
Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: Diff coverage details
Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: See your quality gate settings Change summary preferences |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #351 +/- ##
=======================================
Coverage 89.18% 89.18%
=======================================
Files 2 2
Lines 111 111
=======================================
Hits 99 99
Misses 12 12
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (3)
.github/workflows/python-app.yml (3)
112-115: Consider enabling a full clone for Docker context
By defaultactions/checkout@v4performs a shallow clone (fetch-depth=1), which may omit tags or history required by some workflows. If you need full history or tags inside the container build, addfetch-depth: 0.- - name: Checkout repository - uses: actions/checkout@v4 + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0
116-122: Simplify GHCR login using thetokeninput
docker/login-action@v3supports a singletokenparameter. You can drop the explicitusernameandpasswordfields for brevity:- - name: Log in to GitHub Container Registry - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} + - name: Log in to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + token: ${{ secrets.GITHUB_TOKEN }}
126-134: Add multi-arch support and dynamic branch tagging
By default Buildx will build for the runner’s architecture only. To publish multi-platform images and avoid hardcodingmain, consider:- - name: Build and push Docker image to GitHub Container Registry - uses: docker/build-push-action@v5 - with: - context: . - push: true - tags: | - ghcr.io/${{ github.repository }}:latest - ghcr.io/${{ github.repository }}:main - ghcr.io/${{ github.repository }}:sha-${{ github.sha }} + - name: Build and push multi-architecture Docker image + uses: docker/build-push-action@v5 + with: + context: . + push: true + platforms: linux/amd64,linux/arm64 + tags: | + ghcr.io/${{ github.repository }}:latest + ghcr.io/${{ github.repository }}:${{ github.ref_name }} + ghcr.io/${{ github.repository }}:sha-${{ github.sha }}
platforms: builds and pushes both amd64 and arm64 images.${{ github.ref_name }}: dynamically tags with the branch name rather than hardcodingmain.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
.github/workflows/python-app.yml(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Codacy Static Code Analysis
🔇 Additional comments (3)
.github/workflows/python-app.yml (3)
104-106: Approve container job definition
The newcontainerjob correctly depends oncoverageand uses the sameubuntu-latestrunner as other jobs.
108-110: Approve scoped permissions for GHCR push
Specifyingcontents: readandpackages: writeat the job level aligns with the needs of the Docker login and push steps, and follows least-privilege principles.
123-125: Approve Buildx setup
Usingdocker/setup-buildx-action@v3correctly initializes Docker Buildx for this job.



This change is
Summary by CodeRabbit