mirror of
https://github.com/RetroDECK/retrodeck-builder.git
synced 2024-11-24 15:15:38 +00:00
40 lines
1.1 KiB
YAML
40 lines
1.1 KiB
YAML
name: "Build and Publish Docker Image"
|
|
|
|
on:
|
|
push:
|
|
paths:
|
|
- "Dockerfile" # Trigger only when the Dockerfile is modified
|
|
- ".github/workflows/docker.yml" # Also triggers when the workflow itself is updated
|
|
|
|
env:
|
|
IMAGE_NAME: ghcr.io/retrodeck/retrodeck-builder:${{ github.sha }} # Image name with SHA tag
|
|
|
|
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
|
|
|
|
- name: Tag as Latest
|
|
if: github.ref == 'refs/heads/main' # Only tag as 'latest' on the main branch
|
|
run: |
|
|
docker tag $IMAGE_NAME ghcr.io/retrodeck/retrodeck-builder:latest
|
|
docker push ghcr.io/retrodeck/retrodeck-builder:latest
|