Skip to content

Create docker-image.yml #1

Create docker-image.yml

Create docker-image.yml #1

Workflow file for this run

name: Docker Build and Push to ghcr.io
on:
push:
branches:
- main
tags:
- '*'
jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
run: |
IMAGE_NAME=ghcr.io/${{ github.repository }}
if [[ $GITHUB_REF == refs/tags/* ]]; then
TAG=${GITHUB_REF#refs/tags/}
else
TAG=latest
fi
docker build -t $IMAGE_NAME:$TAG .
docker push $IMAGE_NAME:$TAG