FixMiYouShe/.gitea/workflows/docker.yml
xtaodada 3de12c1de7
All checks were successful
Docker Build / docker build and publish (push) Successful in 1m14s
ci: add Dockerfile
2024-05-16 20:46:58 +08:00

51 lines
1.3 KiB
YAML

name: "Docker Build"
# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the master branch
workflow_dispatch: ~
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
name: docker build and publish
env:
DOCKER_BUILDKIT: 1
DOCKER_CLI_EXPERIMENTAL: enabled
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKERHUB_REPOSITORY: ${{ vars.DOCKER_REPO }}
DOCKER_TAG: 'latest'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Setup Docker Buildx
uses: crazy-max/ghaction-docker-buildx@v3
- name: Buildx cache
uses: actions/cache@v2
id: buildx-cache
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx
- name: Build
run: |
docker buildx build \
--cache-from "type=local,src=/tmp/.buildx-cache" \
--cache-to "type=local,dest=/tmp/.buildx-cache" \
--output "type=image,push=true" \
--platform "linux/amd64" \
--tag "${DOCKERHUB_REPOSITORY}:${DOCKER_TAG}" \
-f Dockerfile \
.