mirror of https://github.com/1N3/Sn1per.git
53 lines
1.3 KiB
YAML
53 lines
1.3 KiB
YAML
name: Build and Push docker
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
- development
|
|
- feat*
|
|
- gh-action
|
|
tags:
|
|
- "v*"
|
|
pull_request:
|
|
branches:
|
|
- master
|
|
|
|
env:
|
|
REGISTRY: ghcr.io
|
|
RAW_IMAGE_NAME: ${{ github.repository }}
|
|
IMAGE_NAME: ${RAW_IMAGE_NAME,,} # Convert repository name to lowercase
|
|
|
|
jobs:
|
|
deploy-docker-hello-world:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
|
|
- name: Docker meta
|
|
id: meta
|
|
uses: docker/metadata-action@v4
|
|
with:
|
|
images: ${{ env.REGISTRY}}/${{ env.IMAGE_NAME }} # Use the original name for metadata
|
|
flavor: latest=true
|
|
tags: |
|
|
type=ref,event=branch
|
|
type=ref,event=pr
|
|
type=semver,pattern={{version}}
|
|
|
|
- name: Login to image repository
|
|
uses: docker/login-action@v2
|
|
with:
|
|
registry: ${{ env.REGISTRY }}
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Build and push
|
|
uses: docker/build-push-action@v2
|
|
with:
|
|
context: .
|
|
file: Dockerfile.base
|
|
push: ${{ github.ref_type == 'tag' || github.ref_name == 'main' || startsWith(github.ref_name, 'feat-')}}
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
labels: ${{ steps.meta.outputs.labels }}
|