Merge pull request #26 from ksek87/dev #14
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Push Docker Image to GitHub Container Registry | |
on: | |
push: | |
branches: | |
- main # Trigger action on push to the 'main' branch | |
pull_request: | |
branches: | |
- main # Trigger action on pull requests to 'main' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
# Step 1: Checkout the code | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
# Step 2: Set up Docker Buildx | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
# Step 3: Log in to GitHub Container Registry | |
- name: Log in to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} # GitHub username | |
password: ${{ secrets.GITHUB_TOKEN }} # GitHub token (automatically available in actions) | |
# Step 4: Build the Docker image | |
- name: Build Docker image | |
run: | | |
docker build -t ghcr.io/${{ github.repository }}:latest . | |
# Step 5: Push the Docker image to GitHub Container Registry | |
- name: Push Docker image | |
run: | | |
docker push ghcr.io/${{ github.repository }}:latest |