UPDATE: baseimage #6
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 GHCR | |
# Run this workflow on push or pull request to the main branch | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
# Step 1: Check out the repository code | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
# Step 2: Set up Docker Buildx for cross-platform builds (optional but recommended) | |
- 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 | |
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin | |
# Step 4: Build and push the Docker image | |
- name: Build and push Docker image | |
run: | | |
REPO_NAME=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]') | |
docker build -t ghcr.io/$REPO_NAME:latest . | |
docker push ghcr.io/$REPO_NAME:latest |