~ dockerhub.yml replaces dockerhub-tag.yml & dockerhub-master.yml (should fix #47)

This commit is contained in:
nicobo 2021-01-25 23:28:10 +01:00
parent b9e0927ce5
commit 560d838e60
No known key found for this signature in database
GPG key ID: 2581E71C5FA5285F
2 changed files with 57 additions and 133 deletions

View file

@ -1,106 +0,0 @@
# 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 (master branch)
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 alpine
id: docker_build_alpine
uses: docker/build-push-action@v2
with:
context: ./
file: ./alpine.Dockerfile
builder: ${{ steps.buildx.outputs.name }}
platforms: linux/arm/v7,linux/arm64,linux/386,linux/amd64
push: true
tags: |
nicolabs/nicobot:alpine-dev
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 }}
- name: Build and push debian
id: docker_build_debian
uses: docker/build-push-action@v2
with:
context: ./
file: ./debian.Dockerfile
builder: ${{ steps.buildx.outputs.name }}
platforms: linux/arm/v7,linux/arm64,linux/386,linux/amd64
push: true
tags: |
nicolabs/nicobot:debian-dev
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-signal
id: docker_build_debian_signal
uses: docker/build-push-action@v2
with:
context: ./
file: ./debian-signal.Dockerfile
builder: ${{ steps.buildx.outputs.name }}
platforms: linux/arm/v7,linux/arm64,linux/386,linux/amd64
push: true
tags: |
nicolabs/nicobot:debian-signal-dev
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_signal.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

View file

@ -1,16 +1,20 @@
# 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
#
# Some refs :
# - Starting : https://docs.docker.com/ci-cd/github-actions/
# - More details here : https://github.com/marketplace/actions/build-and-push-docker-images#update-dockerhub-repo-description
# - Variables (contexts) : https://docs.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#github-context
name: Build and publish to Docker Hub (tagged commit)
name: Docker Hub
on:
push:
branches:
- master
tags:
- "v*.*.*"
jobs:
build-publish:
prepare:
name: Build, Publish
environment: prod
runs-on: ubuntu-latest
@ -20,7 +24,7 @@ jobs:
uses: actions/checkout@v2
##############
# Python is used to get the program's version
# Python is used to get the program's version and generate tags
#
- name: Set up Python
@ -28,24 +32,20 @@ jobs:
with:
python-version: '3.x'
- name: Get program's version
- name: Generate tags
run: |
# Prints Python version
python -c "import sys; print(sys.version)"
python -m pip install --upgrade pip
pip install -r requirements-build.txt
echo NICOBOT_VERSION=$(python setup.py --version) >> $GITHUB_ENV
# Stores a variable for each variant
echo DEBIAN_TAGS=$(python3 setup.py -q docker_tags --image nicolabs/nicobot --variant debian --ref ${{ github.ref }} --sep ,) >> $GITHUB_ENV
echo DEBIAN_SIGNAL_TAGS=$(python3 setup.py -q docker_tags --image nicolabs/nicobot --variant debian-signal --ref ${{ github.ref }} --sep ,) >> $GITHUB_ENV
echo ALPINE_TAGS=$(python3 setup.py -q docker_tags --image nicolabs/nicobot --variant alpine --ref ${{ github.ref }} --sep ,) >> $GITHUB_ENV
# Also stores the computed version
echo NICOBOT_VERSION=$(python3 setup.py --version) >> $GITHUB_ENV
#
##############
- 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
@ -67,6 +67,16 @@ jobs:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
publish-alpine:
name: Publish debian
needs:
- prepare
environment: prod
runs-on: ubuntu-latest
steps:
- name: Build and push alpine
id: docker_build_alpine
uses: docker/build-push-action@v2
@ -76,15 +86,25 @@ jobs:
builder: ${{ steps.buildx.outputs.name }}
platforms: linux/arm/v7,linux/arm64,linux/386,linux/amd64
push: true
tags: |
nicolabs/nicobot:alpine
nicolabs/nicobot:alpine-${{ env.NICOBOT_VERSION }}
tags: ${{ env.ALPINE_TAGS }}
labels: |
${{ env.NICOBOT_VERSION }}
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 }}
publish-debian:
name: Publish alpine
needs:
- prepare
environment: prod
runs-on: ubuntu-latest
steps:
- name: Build and push debian
id: docker_build_debian
uses: docker/build-push-action@v2
@ -94,9 +114,9 @@ jobs:
builder: ${{ steps.buildx.outputs.name }}
platforms: linux/arm/v7,linux/arm64,linux/386,linux/amd64
push: true
tags: |
nicolabs/nicobot:debian
nicolabs/nicobot:debian-${{ env.NICOBOT_VERSION }}
tags: ${{ env.DEBIAN_TAGS }}
labels: |
${{ env.NICOBOT_VERSION }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
@ -112,16 +132,26 @@ jobs:
builder: ${{ steps.buildx.outputs.name }}
platforms: linux/arm/v7,linux/arm64,linux/386,linux/amd64
push: true
tags: |
nicolabs/nicobot:debian-signal
nicolabs/nicobot:debian-signal-${{ env.NICOBOT_VERSION }}
nicolabs/nicobot:latest
tags: ${{ env.DEBIAN_SIGNAL_TAGS }}
labels: |
${{ env.NICOBOT_VERSION }}
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_signal.outputs.digest }}
post:
name: Update repo
needs:
- publish-alpine
- publish-debian
environment: prod
runs-on: ubuntu-latest
steps:
# https://github.com/marketplace/actions/build-and-push-docker-images#update-dockerhub-repo-description
- name: Update repo description
uses: peter-evans/dockerhub-description@v2