Quay.io Github Actions
type: post title: “Set up GitHub Actions to Build and Push Docker Images to Quay.io” date: 2025-03-16 tags: [“quay.io”, “github-actions”, “docker”]
🚀 How to Set Up GitHub Actions to Build and Push Docker Images to Quay.io
If you’re using GitHub Actions to automate your CI/CD workflow, and want to push your Docker images to Quay.io — a secure and reliable container registry — you’re in the right place.
This article walks you through how to:
- Set up a Quay.io repository
- Create a robot account for CI/CD access
- Add GitHub secrets for authentication
- Write a GitHub workflow to build and push your image
🔧 Step 1: Create a Repository on Quay.io
Go to https://quay.io and sign in.
Click “+ New Repository”.
Choose:
- Name (e.g.,
my-app
) - Visibility (Public or Private)
- Namespace: your username or an organization
- Name (e.g.,
Click “Create Repository”.
🤖 Step 2: Create a Robot Account (Recommended for CI/CD)
Go to your namespace page:
https://quay.io/organization/<your-namespace>/robots
(For personal accounts:https://quay.io/user/<your-username>?tab=robots
)Click “Create Robot Account”.
- Example:
ci-bot
- This will generate a username like
yournamespace+ci-bot
- Example:
After creation:
- Copy the generated token/password
Assign the robot write permissions on your repository:
- Go to the repository settings → Permissions tab
- Add the robot account and give it Write or Admin access
🔑 Step 3: Add Secrets to GitHub
In your GitHub repository:
- Go to Settings → Secrets and variables → Actions
- Click “New repository secret” and add:
Name | Value |
---|---|
QUAY_USERNAME | yournamespace+ci-bot |
QUAY_PASSWORD | The robot account token |
🛠 Step 4: Write a GitHub Actions Workflow
Create .github/workflows/docker-build.yml
:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
name: Build and Push Docker Image
on:
push:
branches: [main] # Or your deployment branch
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Log in to Quay.io
run: echo "$" | docker login quay.io -u "$" --password-stdin
- name: Build Docker image
run: |
docker build -t quay.io/$/my-app:latest .
- name: Push Docker image
run: |
docker push quay.io/$/my-app:latest
✅ Optional Enhancements
Tag with Git SHA or date:
1 2 3
IMAGE_TAG=$(git rev-parse --short HEAD) docker build -t quay.io/$/my-app:$IMAGE_TAG . docker push quay.io/$/my-app:$IMAGE_TAG
Support multiple tags (e.g.,
latest
+commit
):1 2 3 4 5
- name: Tag and push run: | SHA=$ docker tag quay.io/...:latest quay.io/...:$SHA docker push quay.io/...:$SHA
🎉 Conclusion
By using a robot account and GitHub secrets, you can securely build and push Docker images to Quay.io in your CI/CD pipeline. Quay.io offers strong security, image scanning, and flexible access control, making it a great alternative to Docker Hub.