mirror of
https://github.com/nicolabs/nicobot.git
synced 2025-09-07 01:40:41 +02:00
~ creating a CI workflow to build & push tagged commits
This commit is contained in:
parent
d3e58ca028
commit
690779a526
|
@ -2,7 +2,7 @@
|
|||
# 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
|
||||
name: Build and publish to Docker Hub (master branch)
|
||||
|
||||
on:
|
||||
push:
|
||||
|
@ -56,7 +56,7 @@ jobs:
|
|||
platforms: linux/arm/v7,linux/arm64,linux/386,linux/amd64
|
||||
push: true
|
||||
tags: |
|
||||
nicolabs/nicobot:alpine
|
||||
nicolabs/nicobot:alpine-dev
|
||||
cache-from: type=local,src=/tmp/.buildx-cache
|
||||
cache-to: type=local,dest=/tmp/.buildx-cache
|
||||
|
||||
|
@ -73,7 +73,7 @@ jobs:
|
|||
platforms: linux/arm/v7,linux/arm64,linux/386,linux/amd64
|
||||
push: true
|
||||
tags: |
|
||||
nicolabs/nicobot:debian
|
||||
nicolabs/nicobot:debian-dev
|
||||
cache-from: type=local,src=/tmp/.buildx-cache
|
||||
cache-to: type=local,dest=/tmp/.buildx-cache
|
||||
|
||||
|
@ -90,8 +90,7 @@ jobs:
|
|||
platforms: linux/arm/v7,linux/arm64,linux/386,linux/amd64
|
||||
push: true
|
||||
tags: |
|
||||
nicolabs/nicobot:debian-signal
|
||||
nicolabs/nicobot:latest
|
||||
nicolabs/nicobot:debian-signal-dev
|
||||
cache-from: type=local,src=/tmp/.buildx-cache
|
||||
cache-to: type=local,dest=/tmp/.buildx-cache
|
||||
|
131
.github/workflows/dockerhub-tag.yml
vendored
Normal file
131
.github/workflows/dockerhub-tag.yml
vendored
Normal file
|
@ -0,0 +1,131 @@
|
|||
# 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 (tagged commit)
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- "v*.*.*"
|
||||
|
||||
jobs:
|
||||
build-publish:
|
||||
name: Build, Publish
|
||||
environment: prod
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
##############
|
||||
# Python is used to get the program's version
|
||||
#
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: '3.x'
|
||||
|
||||
- name: Get program's version
|
||||
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
|
||||
|
||||
#
|
||||
##############
|
||||
|
||||
- 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
|
||||
nicolabs/nicobot:alpine-${{ 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 }}
|
||||
|
||||
- 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
|
||||
nicolabs/nicobot:debian-${{ 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.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
|
||||
nicolabs/nicobot:debian-signal-${{ env.NICOBOT_VERSION }}
|
||||
nicolabs/nicobot:latest
|
||||
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
|
Loading…
Reference in a new issue