Update docker.yml #5
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 on push to the main branch | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- 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 ghcr.io/sonichigo/wallpaper-ai:${{ github.sha }} . | |
- name: Push Docker image | |
run: | | |
docker push ghcr.io/sonichigo/wallpaper-ai:${{ github.sha }} | |
- name: Tag latest image | |
run: | | |
docker tag ghcr.io/sonichigo/wallpaper-ai:${{ github.sha }} ghcr.io/sonichigo/wallpaper-ai:latest | |
- name: Push the "latest" tag | |
run: | | |
docker push ghcr.io/sonichigo/wallpaper-ai:latest |