Update Readme.md
All checks were successful
Build and Publish Docker Image on Commit / build-and-publish (push) Successful in 15s

This commit is contained in:
merith-tk 2024-10-01 16:27:50 -07:00
parent 183ccf5fcc
commit 9c431244ef

View file

@ -2,53 +2,34 @@
## Overview
This repository contains two GitHub Actions workflows designed for automating the build and publishing of Docker images to an OCI registry. The workflows trigger on specific events in your Git repository, ensuring that your Docker images are always up-to-date with the latest commits and tags.
This repository contains two GitHub Actions workflows that automate the building and publishing of Docker images to an OCI registry.
### Workflows
1. **Build and Publish Docker Image on Commit**
- **Trigger:** Activates on commits to the `main` branch, excluding tag pushes.
- **Purpose:** Builds and publishes a Docker image for every commit made to the main branch.
1. **On Commit to Main**
- **Trigger:** Activates on commits to the `main` branch (tags are excluded).
- **Purpose:** Builds and publishes a Docker image for each commit.
2. **Build and Publish Docker Image on Tag**
- **Trigger:** Activates when a new tag is pushed to the repository.
- **Purpose:** Builds and publishes a Docker image for the specific tag and also tags it as `latest` for easier access.
## Workflow Details
### Build and Publish Docker Image on Commit
- **Jobs:**
- **Checkout repository:** Clones the repository to the workflow runner.
- **Test Docker Connection:** Runs a simple Docker command to verify connectivity.
- **Login to OCI Registry:** Authenticates to the OCI registry using stored secrets.
- **Build and Push Docker Image:** Builds a Docker image tagged with the commit SHA and pushes it to the registry.
### Build and Publish Docker Image on Tag
- **Jobs:**
- **Checkout repository:** Clones the repository to the workflow runner.
- **Test Docker Connection:** Runs a simple Docker command to verify connectivity.
- **Login to OCI Registry:** Authenticates to the OCI registry using stored secrets.
- **Build and Push Docker Image:** Builds a Docker image tagged with the Git tag and pushes it to the registry. Additionally, it tags the image as `latest` for easier access.
2. **On Tag Push**
- **Trigger:** Activates when a new tag is pushed.
- **Purpose:** Builds and publishes a Docker image for the tag and tags it as `latest`.
## Prerequisites
- **Secrets Configuration:** Ensure the following secrets are configured in your GitHub repository:
- **Secrets Needed:**
- `OCI_TOKEN`: Your OCI registry token.
- `OCI_USER`: Your OCI registry username.
## How to Use
1. **Clone the Repository:** Clone this template repository to your local machine.
2. **Modify Dockerfile:** Customize the `Dockerfile` as needed for your application.
3. **Push Changes:** Commit and push your changes to the `main` branch or create a tag to trigger the workflows.
4. **Check Workflow Runs:** Monitor the Actions tab in your GitHub repository to see the progress and logs of your workflow runs.
1. **Clone the Repository:** Get a local copy of this repository.
2. **Modify Dockerfile:** Update the `Dockerfile` for your application.
3. **Push Changes:** Push changes to the `main` branch or create a new tag.
4. **Check Workflow Status:** View the Actions tab in Forgjo to monitor workflow runs.
## Notes
- The workflows are designed for use with a Docker builder environment.
- Ensure your Docker setup is compatible with multi-platform builds if you plan to use that feature.
- Ensure your Docker environment is compatible with multi-platform builds if necessary.
## License