-
Notifications
You must be signed in to change notification settings - Fork 0
fix: add Docker Hub authentication to CI workflow #37
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,44 @@ | ||||||||
| # Docker Hub Authentication Setup for CI | ||||||||
|
|
||||||||
| ## Problem | ||||||||
| GitHub Actions CI workflows were failing with Docker Hub authentication errors: | ||||||||
| ``` | ||||||||
| unauthorized: authentication required | ||||||||
| ``` | ||||||||
|
|
||||||||
| This happens when GitHub Actions tries to pull Docker images (postgres:15, redis:7) but hits Docker Hub rate limits for unauthenticated requests. | ||||||||
|
|
||||||||
| ## Solution Implemented | ||||||||
|
|
||||||||
| ### 1. CI Workflow Changes | ||||||||
| - Added Docker Hub credential environment variables to the workflow | ||||||||
| - Added Docker login step before jobs that use Docker service containers | ||||||||
| - Made authentication optional with `continue-on-error: true` so CI still works without credentials | ||||||||
|
|
||||||||
| ### 2. Required GitHub Secrets Setup | ||||||||
|
|
||||||||
| To enable Docker Hub authentication, add these secrets to your repository: | ||||||||
|
|
||||||||
| 1. Go to Settings → Secrets and variables → Actions | ||||||||
| 2. Add two new repository secrets: | ||||||||
| - `DOCKERHUB_USERNAME`: Your Docker Hub username | ||||||||
| - `DOCKERHUB_TOKEN`: Your Docker Hub access token (NOT your password) | ||||||||
|
|
||||||||
| ### 3. How to Create Docker Hub Access Token | ||||||||
|
|
||||||||
| 1. Log in to [Docker Hub](https://hub.docker.com) | ||||||||
| 2. Click on your username → Account Settings | ||||||||
| 3. Select "Security" → "New Access Token" | ||||||||
| 4. Give it a descriptive name like "GitHub Actions CI" | ||||||||
| 5. Copy the token and save it as `DOCKERHUB_TOKEN` secret in GitHub | ||||||||
|
|
||||||||
| ## Benefits | ||||||||
| - Avoids Docker Hub rate limits (100 pulls/6hr for anonymous vs 200 pulls/6hr for authenticated) | ||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To provide an authoritative source for the rate limit figures, it's helpful to link to the official Docker Hub documentation. This allows users to verify the information and stay informed about any changes to Docker's policies.
Suggested change
|
||||||||
| - CI runs more reliably without authentication failures | ||||||||
| - Optional - CI still works without credentials, just with lower rate limits | ||||||||
|
|
||||||||
| ## Files Modified | ||||||||
| - `.github/workflows/ci.yml`: Added Docker authentication steps | ||||||||
|
|
||||||||
| ## Testing | ||||||||
| After adding the secrets, the CI will automatically use Docker Hub authentication for all Docker image pulls. | ||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is a standard convention for text files to end with a single newline character. Some tools may have issues processing files that lack a final newline. Please add one to adhere to this best practice.
Suggested change
|
||||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -25,6 +25,9 @@ permissions: | |||||
| env: | ||||||
| FLUTTER_VERSION: '3.35.3' | ||||||
| RUST_VERSION: '1.89.0' | ||||||
| # Docker Hub credentials - optional but recommended to avoid rate limits | ||||||
| DOCKER_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} | ||||||
| DOCKER_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} | ||||||
|
|
||||||
| concurrency: | ||||||
| group: core-ci-${{ github.ref }}-${{ github.event_name }} | ||||||
|
|
@@ -275,6 +278,14 @@ jobs: | |||||
| steps: | ||||||
| - uses: actions/checkout@v4 | ||||||
|
|
||||||
| - name: Login to Docker Hub | ||||||
| if: env.DOCKER_USERNAME != '' && env.DOCKER_TOKEN != '' | ||||||
|
||||||
| if: env.DOCKER_USERNAME != '' && env.DOCKER_TOKEN != '' | |
| if: env.DOCKER_USERNAME && env.DOCKER_TOKEN |
Copilot uses AI. Check for mistakes.
Copilot
AI
Sep 25, 2025
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.
Same issue as the previous Docker login step - the condition checks for non-empty strings, but GitHub Actions environment variables are undefined when secrets don't exist. Use if: env.DOCKER_USERNAME && env.DOCKER_TOKEN instead.
| if: env.DOCKER_USERNAME != '' && env.DOCKER_TOKEN != '' | |
| if: env.DOCKER_USERNAME && env.DOCKER_TOKEN |
Copilot uses AI. Check for mistakes.
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.
The PostgreSQL version
postgres:15mentioned here is inconsistent with thepostgres:16-alpineversion specified in the project'sdocker-compose.yml. While the CI environment might use a different version, this discrepancy can be confusing for developers. To improve clarity, please ensure the version number in the documentation is accurate for the context it describes (CI).