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 ## 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 ### Workflows
1. **Build and Publish Docker Image on Commit** 1. **On Commit to Main**
- **Trigger:** Activates on commits to the `main` branch, excluding tag pushes. - **Trigger:** Activates on commits to the `main` branch (tags are excluded).
- **Purpose:** Builds and publishes a Docker image for every commit made to the main branch. - **Purpose:** Builds and publishes a Docker image for each commit.
2. **Build and Publish Docker Image on Tag** 2. **On Tag Push**
- **Trigger:** Activates when a new tag is pushed to the repository. - **Trigger:** Activates when a new tag is pushed.
- **Purpose:** Builds and publishes a Docker image for the specific tag and also tags it as `latest` for easier access. - **Purpose:** Builds and publishes a Docker image for the tag and tags it as `latest`.
## 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.
## Prerequisites ## Prerequisites
- **Secrets Configuration:** Ensure the following secrets are configured in your GitHub repository: - **Secrets Needed:**
- `OCI_TOKEN`: Your OCI registry token. - `OCI_TOKEN`: Your OCI registry token.
- `OCI_USER`: Your OCI registry username. - `OCI_USER`: Your OCI registry username.
## How to Use ## How to Use
1. **Clone the Repository:** Clone this template repository to your local machine. 1. **Clone the Repository:** Get a local copy of this repository.
2. **Modify Dockerfile:** Customize the `Dockerfile` as needed for your application. 2. **Modify Dockerfile:** Update the `Dockerfile` for your application.
3. **Push Changes:** Commit and push your changes to the `main` branch or create a tag to trigger the workflows. 3. **Push Changes:** Push changes to the `main` branch or create a new tag.
4. **Check Workflow Runs:** Monitor the Actions tab in your GitHub repository to see the progress and logs of your workflow runs. 4. **Check Workflow Status:** View the Actions tab in Forgjo to monitor workflow runs.
## Notes ## Notes
- The workflows are designed for use with a Docker builder environment. - Ensure your Docker environment is compatible with multi-platform builds if necessary.
- Ensure your Docker setup is compatible with multi-platform builds if you plan to use that feature.
## License ## License