Create Build.yml
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
name: "Build and push images"
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
Building:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
actions: write
|
||||
|
||||
name: "Build image"
|
||||
env:
|
||||
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} # Docker Hub 用户名
|
||||
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} # Docker Hub 密码
|
||||
DOCKER_REPO: ${{ secrets.DOCKER_REPO }} # Docker Hub 仓库名(示例:argo-nezha-v1)
|
||||
MIRROR_LABEL: ${{ secrets.MIRROR_LABEL }} # 镜像标签(留空为latest)
|
||||
DOCKERHUB_REPOSITORY: ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPO }}:${{ secrets.MIRROR_LABEL }} # 构造标签
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4.1.1
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Delete workflow runs
|
||||
uses: Mattraks/delete-workflow-runs@v2
|
||||
with:
|
||||
token: ${{ github.token }}
|
||||
repository: ${{ github.repository }}
|
||||
retain_days: 0
|
||||
keep_minimum_runs: 2
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3.0.0
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3.0.0
|
||||
|
||||
- name: Login to DockerHub
|
||||
uses: docker/login-action@v3.0.0
|
||||
with:
|
||||
username: ${{ env.DOCKER_USERNAME }}
|
||||
password: ${{ env.DOCKER_PASSWORD }}
|
||||
|
||||
- name: Print Docker Buildx Version
|
||||
run: docker buildx version
|
||||
|
||||
- name: Push images to Docker hub
|
||||
uses: docker/build-push-action@v5.1.0
|
||||
with:
|
||||
push: true
|
||||
platforms: linux/amd64
|
||||
tags: ${{ env.DOCKERHUB_REPOSITORY }} # 使用环境变量构建的 Docker Hub 仓库地址和标签
|
||||
Reference in New Issue
Block a user