优化启动提示 #154
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: 'buildx docker images' | |
on: | |
push: | |
branches: | |
- master | |
tags: | |
- "v*" | |
jobs: | |
docker: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@master | |
with: | |
platforms: all | |
- name: Set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@master | |
- name: Login to DockerHub | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@v3 | |
with: | |
images: ${{ github.repository }} | |
- name: Prepare Build Args | |
id: prep | |
run: | | |
# If this is git tag, use the tag name as a docker tag | |
if [[ $GITHUB_REF == refs/tags/* ]]; then | |
VERSION=${GITHUB_REF#refs/tags/} | |
else | |
VERSION=${GITHUB_SHA::8} | |
fi | |
BUILD_ARGS="GIT_VERSION=${VERSION}" | |
echo "Build args: ${BUILD_ARGS}" | |
# Set output parameters.ash | |
echo ::set-output name=build_args::${BUILD_ARGS} | |
- name: Build Image | |
id: build | |
uses: docker/build-push-action@v2 | |
with: | |
builder: ${{ steps.buildx.outputs.name }} | |
context: . | |
platforms: linux/amd64,linux/arm64 | |
labels: ${{ steps.meta.outputs.labels }} | |
push: ${{ github.event_name != 'pull_request' }} | |
cache-from: type=registry,ref=talebook/talebook:latest | |
cache-to: type=inline | |
tags: | | |
${{ steps.meta.outputs.tags }} | |
talebook/calibre-webserver:latest | |
build-args: | | |
${{ steps.prep.outputs.build_args }} | |