2021-04-28 01:41:55 +02:00
|
|
|
name: Publish Docker image
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- '**'
|
|
|
|
tags:
|
|
|
|
- 'v*'
|
|
|
|
jobs:
|
|
|
|
push_to_registry:
|
|
|
|
name: Build and push docker image
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Checkout
|
2022-03-02 15:14:42 +01:00
|
|
|
uses: actions/checkout@v3
|
2021-04-28 01:41:55 +02:00
|
|
|
- name: Docker meta
|
|
|
|
id: docker_meta
|
2022-05-05 16:14:18 +02:00
|
|
|
uses: docker/metadata-action@v4
|
2021-04-28 01:41:55 +02:00
|
|
|
with:
|
2021-04-28 02:02:36 +02:00
|
|
|
images: ${{ secrets.DOCKERHUB_USERNAME }}/docker-network-graph,ghcr.io/${{ github.repository_owner }}/docker-network-graph
|
2021-04-28 01:41:55 +02:00
|
|
|
tags: |
|
|
|
|
type=ref,event=branch
|
|
|
|
type=semver,pattern={{version}}
|
|
|
|
type=semver,pattern={{major}}.{{minor}}
|
|
|
|
- name: Checkout
|
2022-03-02 15:14:42 +01:00
|
|
|
uses: actions/checkout@v3
|
2021-04-28 01:41:55 +02:00
|
|
|
- name: Set up QEMU
|
|
|
|
uses: docker/setup-qemu-action@v1
|
|
|
|
- name: Set up Docker Buildx
|
|
|
|
uses: docker/setup-buildx-action@v1
|
|
|
|
- name: Cache Docker layers
|
2021-04-28 02:02:36 +02:00
|
|
|
if: github.event_name != 'pull_request'
|
2022-03-21 15:13:27 +01:00
|
|
|
uses: actions/cache@v3
|
2021-04-28 01:41:55 +02:00
|
|
|
with:
|
|
|
|
path: /tmp/.buildx-cache
|
|
|
|
key: ${{ runner.os }}-buildx-${{ github.sha }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-buildx-
|
|
|
|
- name: Login to DockerHub
|
|
|
|
uses: docker/login-action@v1
|
|
|
|
with:
|
|
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
- name: Login to GitHub Container Registry
|
|
|
|
if: github.event_name != 'pull_request'
|
|
|
|
uses: docker/login-action@v1
|
|
|
|
with:
|
|
|
|
registry: ghcr.io
|
2021-04-28 02:02:36 +02:00
|
|
|
username: ${{ github.repository_owner }}
|
|
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
2021-04-28 01:41:55 +02:00
|
|
|
- name: Build and push
|
|
|
|
uses: docker/build-push-action@v2
|
|
|
|
with:
|
|
|
|
context: .
|
|
|
|
file: ./Dockerfile
|
|
|
|
platforms: linux/amd64,linux/386,linux/arm/v6,linux/arm/v7,linux/arm64
|
|
|
|
push: True
|
|
|
|
tags: ${{ steps.docker_meta.outputs.tags }}
|
|
|
|
labels: ${{ steps.docker_meta.outputs.labels }}
|
|
|
|
cache-from: type=local,src=/tmp/.buildx-cache
|
|
|
|
cache-to: type=local,dest=/tmp/.buildx-cache
|