nicobot/.github/workflows/dockerhub.yml
2020-12-23 22:08:43 +01:00

64 lines
1.8 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
# Download and Install IBM Cloud CLI
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- 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-
# Build the Docker image
- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
context: ./
file: ./Dockerfile-alpine
builder: ${{ steps.buildx.outputs.name }}
push: true
tags: nicolabs/nicobot:dev
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
# Push the image to IBM Container Registry
- name: Image digest
run: echo ${{ steps.docker_build.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