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: Docker Build and Push to GHCR | |
on: | |
push: | |
branches: | |
- main # Trigger on push to main branch | |
tags: | |
- 'v*' # Trigger on tags starting with 'v' | |
jobs: | |
build-and-push: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Log in to GHCR | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GHCR_TOKEN }} | |
- name: Build Docker image | |
run: docker build -t ghcr.io/looijijohn/docks:latest . | |
- name: Push Docker image | |
run: | | |
docker push ghcr.io/looijijohn/docks:latest | |
if [[ "${{ github.ref }}" == refs/tags/* ]]; then | |
docker tag ghcr.io/looijijohn/docks:latest ghcr.io/looijijohn/docks:${{ github.ref_name }} | |
docker push ghcr.io/looijijohn/docks:${{ github.ref_name }} | |
fi |