mirror of
https://github.com/nicolabs/nicobot.git
synced 2025-09-07 05:14:01 +02:00
107 lines
3.2 KiB
YAML
107 lines
3.2 KiB
YAML
# Just followed https://docs.docker.com/ci-cd/github-actions/
|
|
# Also, more details here : https://github.com/marketplace/actions/build-and-push-docker-images#update-dockerhub-repo-description
|
|
#
|
|
|
|
name: Build and publish to Docker Hub
|
|
|
|
on:
|
|
push:
|
|
branches: [master]
|
|
|
|
jobs:
|
|
build-publish:
|
|
name: Build, Publish
|
|
environment: prod
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
|
|
- name: Checkout
|
|
uses: actions/checkout@v2
|
|
|
|
- name: Docker meta
|
|
id: docker_meta
|
|
uses: crazy-max/ghaction-docker-meta@v1
|
|
with:
|
|
images: name/app # list of Docker images to use as base name for tags
|
|
tag-sha: true # add git short SHA as Docker tag
|
|
|
|
- name: Set up QEMU for multiarch
|
|
uses: docker/setup-qemu-action@v1
|
|
|
|
- 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
|
|
uses: docker/login-action@v1
|
|
with:
|
|
username: ${{ secrets.DOCKER_HUB_USERNAME }}
|
|
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
|
|
|
|
- name: Build and push debian
|
|
id: docker_build_debian
|
|
uses: docker/build-push-action@v2
|
|
with:
|
|
context: ./
|
|
file: ./Dockerfile-debian
|
|
builder: ${{ steps.buildx.outputs.name }}
|
|
platforms: linux/386,linux/amd64
|
|
push: true
|
|
tags: |
|
|
nicolabs/nicobot:debian
|
|
cache-from: type=local,src=/tmp/.buildx-cache
|
|
cache-to: type=local,dest=/tmp/.buildx-cache
|
|
|
|
- name: Image digest
|
|
run: echo ${{ steps.docker_build_debian.outputs.digest }}
|
|
|
|
- name: Build and push debian-slim
|
|
id: docker_build_debian_slim
|
|
uses: docker/build-push-action@v2
|
|
with:
|
|
context: ./
|
|
file: ./Dockerfile-debian-slim
|
|
builder: ${{ steps.buildx.outputs.name }}
|
|
platforms: linux/amd64
|
|
push: true
|
|
tags: |
|
|
nicolabs/nicobot:debian-slim
|
|
cache-from: type=local,src=/tmp/.buildx-cache
|
|
cache-to: type=local,dest=/tmp/.buildx-cache
|
|
|
|
- name: Image digest
|
|
run: echo ${{ steps.docker_build_debian_slim.outputs.digest }}
|
|
|
|
- name: Build and push alpine
|
|
id: docker_build_alpine
|
|
uses: docker/build-push-action@v2
|
|
with:
|
|
context: ./
|
|
file: ./Dockerfile-alpine
|
|
builder: ${{ steps.buildx.outputs.name }}
|
|
platforms: linux/amd64
|
|
push: true
|
|
tags: |
|
|
nicolabs/nicobot:alpine
|
|
cache-from: type=local,src=/tmp/.buildx-cache
|
|
cache-to: type=local,dest=/tmp/.buildx-cache
|
|
|
|
- name: Image digest
|
|
run: echo ${{ steps.docker_build_alpine.outputs.digest }}
|
|
|
|
# https://github.com/marketplace/actions/build-and-push-docker-images#update-dockerhub-repo-description
|
|
- name: Update repo description
|
|
uses: peter-evans/dockerhub-description@v2
|
|
with:
|
|
username: ${{ secrets.DOCKER_HUB_USERNAME }}
|
|
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
|
|
repository: nicolabs/nicobot
|