Skip to content

Commit

Permalink
ci: update docker build pipeline from template
Browse files Browse the repository at this point in the history
  • Loading branch information
tanlin2013 committed Jan 31, 2023
1 parent 19d4cd1 commit 0315889
Showing 1 changed file with 26 additions and 17 deletions.
43 changes: 26 additions & 17 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,48 @@
name: docker-build
name: Docker build

on:
push:
branches:
- 'main'
tags:
- 'v*'

jobs:
docker:
build:
runs-on: ubuntu-latest
steps:
- name: Get current date
id: date
run: echo "::set-output name=date::$(date +'%Y-%m-%d.%H.%M')"

- name: Checkout
uses: actions/checkout@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v1
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v2

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ github.repository }}
tags: |
type=schedule
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=sha,format=long
type=raw,value={{date 'YYYYMMDD-hhmmss' tz='Asia/Taipei'}}
type=raw,value=latest
- name: Login to DockerHub
uses: docker/login-action@v1
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
uses: docker/build-push-action@v3
with:
context: .
cache-from: type=gha
cache-to: type=gha,mode=max
push: true
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/tnpy:${{ steps.date.outputs.date }}
${{ secrets.DOCKERHUB_USERNAME }}/tnpy:latest
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

0 comments on commit 0315889

Please sign in to comment.