spoticord/.github/workflows/build-push.yml

64 lines
1.9 KiB
YAML
Raw Normal View History

name: Build and push to registry
2022-12-01 13:34:41 +00:00
on:
push:
branches: [ "main", "dev" ]
tags: [ "v*.*.*" ]
pull_request:
branches: [ "main", "dev" ]
workflow_dispatch:
2022-12-01 13:34:41 +00:00
jobs:
build-and-push:
name: Build Docker image and push to registry
2022-12-01 13:34:41 +00:00
runs-on: ubuntu-latest
2023-09-24 19:15:30 +00:00
permissions:
packages: write
contents: read
2022-12-01 13:34:41 +00:00
steps:
- name: Checkout code
uses: actions/checkout@v3
2022-12-01 13:34:41 +00:00
- name: Set up Docker buildx
id: buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub's container registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Generate image metadata
id: spoticord # used in next step
uses: docker/metadata-action@v5
with:
# list of Docker images to use as base name for tags
images: |
2023-09-24 20:09:06 +00:00
ghcr.io/spoticordmusic/spoticord
# Docker tags based on the following events/attributes
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
2022-12-01 13:34:41 +00:00
- name: Build image and push to registry
uses: docker/build-push-action@v5
2022-12-01 13:34:41 +00:00
with:
context: .
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.spoticord.outputs.tags }}
labels: ${{ steps.spoticord.outputs.labels }}
# Some basic caching of the layers...
2023-09-24 20:09:06 +00:00
cache-from: ghcr.io/spoticordmusic/spoticord:latest-cache
cache-to: ghcr.io/spoticordmusic/spoticord:latest-cache