2021-06-20 21:27:59 +03:00
|
|
|
name: Docker Automated Builds
|
2021-06-11 21:41:03 +03:00
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- main
|
2021-10-02 00:08:08 +03:00
|
|
|
tags:
|
|
|
|
- "v*.*.*"
|
2021-09-25 23:06:40 +03:00
|
|
|
pull_request:
|
|
|
|
branches:
|
|
|
|
- main
|
2021-06-11 21:41:03 +03:00
|
|
|
|
|
|
|
jobs:
|
2021-09-25 23:06:40 +03:00
|
|
|
docker:
|
|
|
|
name: Docker Build and Push
|
2021-09-25 21:43:24 +03:00
|
|
|
runs-on: ubuntu-20.04
|
2021-06-11 21:41:03 +03:00
|
|
|
steps:
|
2021-06-15 00:51:32 +03:00
|
|
|
- name: Checkout
|
2021-09-25 21:36:22 +03:00
|
|
|
uses: actions/checkout@v2
|
2021-09-25 22:00:48 +03:00
|
|
|
|
2021-09-25 23:06:40 +03:00
|
|
|
- name: Docker meta
|
|
|
|
id: meta
|
|
|
|
uses: docker/metadata-action@v3
|
|
|
|
with:
|
|
|
|
images: |
|
2021-09-28 22:02:05 +03:00
|
|
|
orhunp/git-cliff
|
2021-09-25 23:18:28 +03:00
|
|
|
ghcr.io/${{ github.repository_owner }}/git-cliff/git-cliff
|
2021-09-25 23:06:40 +03:00
|
|
|
tags: |
|
|
|
|
type=schedule
|
|
|
|
type=ref,event=branch
|
|
|
|
type=ref,event=pr
|
|
|
|
type=sha
|
2021-09-25 23:22:21 +03:00
|
|
|
type=raw,value=latest
|
2021-10-02 00:08:08 +03:00
|
|
|
type=semver,pattern={{version}}
|
2021-09-25 23:06:40 +03:00
|
|
|
|
2021-09-25 22:00:48 +03:00
|
|
|
- name: Set up Docker Buildx
|
|
|
|
id: buildx
|
|
|
|
uses: docker/setup-buildx-action@v1
|
|
|
|
|
|
|
|
- name: Cache Docker layers
|
|
|
|
uses: actions/cache@v2
|
|
|
|
with:
|
|
|
|
path: /tmp/.buildx-cache
|
|
|
|
key: ${{ runner.os }}-buildx-${{ github.sha }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-buildx-
|
|
|
|
|
|
|
|
- name: Login to Docker Hub
|
2021-09-25 23:06:40 +03:00
|
|
|
if: github.event_name != 'pull_request'
|
2021-09-25 22:00:48 +03:00
|
|
|
uses: docker/login-action@v1
|
|
|
|
with:
|
|
|
|
username: ${{ secrets.DOCKER_HUB_USERNAME }}
|
|
|
|
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
|
|
|
|
|
2021-09-25 23:06:40 +03:00
|
|
|
- name: Login to GHCR
|
|
|
|
if: github.event_name != 'pull_request'
|
|
|
|
uses: docker/login-action@v1
|
|
|
|
with:
|
|
|
|
registry: ghcr.io
|
|
|
|
username: ${{ github.repository_owner }}
|
|
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
|
2021-09-25 22:00:48 +03:00
|
|
|
- name: Build and push
|
|
|
|
id: docker_build
|
|
|
|
uses: docker/build-push-action@v2
|
|
|
|
with:
|
|
|
|
context: ./
|
|
|
|
file: ./Dockerfile
|
|
|
|
builder: ${{ steps.buildx.outputs.name }}
|
2021-09-25 23:06:40 +03:00
|
|
|
push: ${{ github.event_name != 'pull_request' }}
|
|
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
|
|
labels: ${{ steps.meta.outputs.labels }}
|
2021-09-25 22:00:48 +03:00
|
|
|
cache-from: type=local,src=/tmp/.buildx-cache
|
|
|
|
cache-to: type=local,dest=/tmp/.buildx-cache
|
|
|
|
|
|
|
|
- name: Image digest
|
|
|
|
run: echo ${{ steps.docker_build.outputs.digest }}
|