mirror of
https://github.com/LLM-Red-Team/step-free-api.git
synced 2026-01-13 07:00:39 +08:00
67 lines
2.1 KiB
YAML
67 lines
2.1 KiB
YAML
name: Build and Push Docker Image
|
|
|
|
on:
|
|
release:
|
|
types: [created]
|
|
workflow_dispatch:
|
|
inputs:
|
|
tag:
|
|
description: 'Tag Name'
|
|
required: true
|
|
|
|
jobs:
|
|
build-and-push:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v2
|
|
|
|
- name: Docker Setup QEMU
|
|
uses: docker/setup-qemu-action@v1
|
|
|
|
- name: Docker Setup Buildx
|
|
uses: docker/setup-buildx-action@v1
|
|
|
|
- name: Docker Login to Docker Hub
|
|
uses: docker/login-action@v1
|
|
with:
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
|
|
|
- name: Docker Login to GHCR
|
|
uses: docker/login-action@v2
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Set tag name
|
|
id: tag_name
|
|
run: |
|
|
if [ "${{ github.event_name }}" = "release" ]; then
|
|
echo "::set-output name=tag::${GITHUB_REF#refs/tags/}"
|
|
elif [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
|
|
echo "::set-output name=tag::${{ github.event.inputs.tag }}"
|
|
fi
|
|
|
|
- name: Set Docker repository names
|
|
id: repo-set
|
|
run: |
|
|
echo "::set-output name=repo_all::$(echo "${{ github.repository }}" | awk '{print tolower($0)}')"
|
|
echo "::set-output name=repo_name::$(echo "${{ github.event.repository.name }}" | awk '{print tolower($0)}')"
|
|
|
|
- name: Build and push Docker image
|
|
uses: docker/build-push-action@v4
|
|
with:
|
|
context: .
|
|
file: ./Dockerfile
|
|
push: true
|
|
tags: |
|
|
vinlic/${{ steps.repo-set.outputs.repo_name }}:${{ steps.tag_name.outputs.tag }}
|
|
vinlic/${{ steps.repo-set.outputs.repo_name }}:latest
|
|
ghcr.io/${{ steps.repo-set.outputs.repo_all }}:${{ steps.tag_name.outputs.tag }}
|
|
ghcr.io/${{ steps.repo-set.outputs.repo_all }}:latest
|
|
platforms: linux/amd64,linux/arm64
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|