NexusDash-izebra/.github/workflows/ci.yml

55 lines
1.4 KiB
YAML
Raw Normal View History

2023-01-01 01:20:16 +00:00
name: ci
2023-01-01 00:24:19 +00:00
on:
push:
2023-01-01 01:20:16 +00:00
branches:
- "main"
2023-01-01 01:20:16 +00:00
tags:
- "v*.*.*"
pull_request:
branches:
- "main"
2023-01-01 00:24:19 +00:00
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Log in to the Container registry
2023-12-31 07:57:16 +00:00
uses: docker/login-action@v3
2023-01-01 00:24:19 +00:00
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
2023-12-31 07:57:16 +00:00
uses: docker/metadata-action@v5
2023-01-01 00:24:19 +00:00
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
2023-01-01 01:20:16 +00:00
# generate Docker tags based on the following events/attributes
tags: |
type=ref,event=pr
2023-01-01 01:24:47 +00:00
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
2023-01-01 01:20:16 +00:00
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
2023-01-01 00:24:19 +00:00
- name: Build and push Docker image
2023-12-31 07:57:16 +00:00
uses: docker/build-push-action@v5
2023-01-01 00:24:19 +00:00
with:
context: .
2023-01-01 01:20:16 +00:00
push: ${{ github.event_name != 'pull_request' }}
2023-01-01 00:24:19 +00:00
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}