Skip to content

docker

docker #712

name: docker
on:
schedule:
- cron: '32 20 * * *'
push:
branches: [ "main" ]
tags: [ 'v*.*.*' ]
pull_request:
branches: [ "main" ]
env:
REGISTRY: registry.cn-qingdao.aliyuncs.com
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
id-token: write
strategy:
fail-fast: false
matrix:
include:
- service: runner
path: .
image: duke1616/etask
binary: etask
- service: execute
path: ./cmd/execute
image: duke1616/etask-execute
binary: etask-execute
- service: scheduler
path: ./cmd/scheduler
image: duke1616/etask-scheduler
binary: etask-scheduler
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Find Latest Tags
id: octokit
uses: oprypin/find-latest-tag@v1
with:
repository: Duke1616/ecmdb
releases-only: false
- name: Set up Docker build
uses: docker/setup-buildx-action@v3
with:
driver: docker
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ matrix.image }}
- name: Login into registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.ALIYUN_USERNAME }}
password: ${{ secrets.ALIYUN_PASSWORD }}
- name: Build and push ${{ matrix.service }}
id: build-and-push
uses: docker/build-push-action@v5
with:
context: .
file: ./deploy/Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
VERSION=${{ steps.octokit.outputs.tag }}
SERVICE_PATH=${{ matrix.path }}
SERVICE_NAME=${{ matrix.binary }}