retrodeck-builder/.github/workflows/docker.yml

40 lines
1.1 KiB
YAML
Raw Permalink Normal View History

2024-11-05 05:22:20 +00:00
name: "Build and Publish Docker Image"
on:
push:
paths:
- "Dockerfile" # Trigger only when the Dockerfile is modified
2024-11-05 05:28:26 +00:00
- ".github/workflows/docker.yml" # Also triggers when the workflow itself is updated
2024-11-05 05:22:20 +00:00
env:
2024-11-05 05:32:53 +00:00
IMAGE_NAME: ghcr.io/retrodeck/retrodeck-builder:${{ github.sha }} # Image name with SHA tag
2024-11-05 05:22:20 +00:00
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build Docker Image
run: |
docker build -t $IMAGE_NAME .
- name: Push Docker Image to GitHub Container Registry
run: |
docker push $IMAGE_NAME
2024-11-05 05:28:26 +00:00
- name: Tag as Latest
2024-11-05 05:22:20 +00:00
if: github.ref == 'refs/heads/main' # Only tag as 'latest' on the main branch
run: |
2024-11-05 05:32:53 +00:00
docker tag $IMAGE_NAME ghcr.io/retrodeck/retrodeck-builder:latest
docker push ghcr.io/retrodeck/retrodeck-builder:latest