This repository has been archived on 2022-08-18. You can view files and clone it, but cannot push or open issues or pull requests.
rageshake/.github/workflows/docker.yaml

74 lines
2 KiB
YAML
Raw Normal View History

name: Docker
on:
push:
pull_request:
branches: [ master ]
jobs:
build:
name: Build and push Docker image
runs-on: ubuntu-latest
env:
IMAGE: ghcr.io/${{ github.repository }}
permissions:
packages: write
contents: read
steps:
- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
images: "${{ env.IMAGE }}"
bake-target: docker-metadata-action
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
with:
config-inline: |
[registry."docker.io"]
mirrors = ["mirror.gcr.io"]
- name: Login to GitHub Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build
uses: docker/build-push-action@v2
if: github.event_name == 'pull_request'
with:
platforms: |
linux/amd64
linux/arm64
linux/arm
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=${{ env.IMAGE }}:buildcache
- name: Build and push
uses: docker/build-push-action@v2
if: github.event_name != 'pull_request'
with:
platforms: |
linux/amd64
linux/arm64
linux/arm
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
push: true
cache-from: type=registry,ref=${{ env.IMAGE }}:buildcache
cache-to: type=registry,ref=${{ env.IMAGE }}:buildcache,mode=max