You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Create a workflow file in your repository (e.g., .github/workflows/docker-image.yml).
Define the workflow:
name: Build and Push Docker Image on Releaseon:
release:
types: [published]jobs:
build:
runs-on: ubuntu-lateststeps:
- name: Checkout codeuses: actions/checkout@v3
- name: Set up Docker Buildxuses: docker/setup-buildx-action@v3
- name: Login to Docker Hubuses: docker/login-action@v3with:
username: ${{ secrets.DOCKERHUB_USERNAME }}password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push Docker imageuses: docker/build-push-action@v6with:
context: .push: truetags: user/app:${{ github.sha }}
Explanation:
Trigger: The workflow triggers on a release event, specifically when a release is published.
Jobs: The build job runs on the latest Ubuntu runner.
Steps:
Checkout code: Uses the actions/checkout action to check out the repository.
Set up Docker Buildx: Uses the docker/setup-buildx-action to set up Docker Buildx.
Login to Docker Hub: Uses the docker/login-action to log in to Docker Hub using secrets for the username and password.
Build and push Docker image: Uses the docker/build-push-action to build and push the Docker image to Docker Hub. The image is tagged with the commit SHA for uniqueness.
Secrets:
DOCKERHUB_USERNAME: Your Docker Hub username.
DOCKERHUB_TOKEN: Your Docker Hub access token.
You can store these secrets in your GitHub repository settings under Settings > Secrets and variables > Actions.
This setup ensures that your Docker image is built and pushed to Docker Hub only when a new release is published,
The text was updated successfully, but these errors were encountered:
Here is a possible solution
Create a workflow file in your repository (e.g.,
.github/workflows/docker-image.yml
).Define the workflow:
Explanation:
Secrets:
DOCKERHUB_USERNAME
: Your Docker Hub username.DOCKERHUB_TOKEN
: Your Docker Hub access token.You can store these secrets in your GitHub repository settings under Settings > Secrets and variables > Actions.
This setup ensures that your Docker image is built and pushed to Docker Hub only when a new release is published,
The text was updated successfully, but these errors were encountered: