Build Docker Image & Pack Source Code #11
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: Build Docker Image | |
on: | |
workflow_dispatch: | |
push: | |
# 每次 push tag 时进行构建,不需要每次 push 都构建。使用通配符匹配每次 tag 的提交,记得 tag 名一定要以 v 开头 | |
#push: | |
branches: | |
- main | |
tags: | |
- v* | |
paths-ignore: | |
- "test/*" | |
- "LICENSE" | |
- "*.md" | |
env: | |
# 设置 docker 镜像名 | |
IMAGE_NAME: baiduwp-php | |
jobs: | |
multiarch-build-debian: | |
name: Build and publish Debian image | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Retrieve baiduwp version | |
id: baiduwp_version | |
run: echo "VERSION=$(git describe --tags)" >> "$GITHUB_OUTPUT" | |
- name: Get Docker tags for Debian based image | |
id: docker_meta_debian | |
uses: docker/metadata-action@v4 | |
with: | |
images: | | |
ghcr.io/birdxs/baiduwp | |
birdxs/baiduwp | |
#jwilder/baiduwp | |
tags: | | |
type=semver,pattern={{version}} | |
type=semver,pattern={{major}}.{{minor}} | |
type=raw,value=latest,enable={{is_default_branch}} | |
labels: | | |
org.opencontainers.image.authors=birdxs <[email protected]> (@buchdag), Jason Wilder | |
org.opencontainers.image.version=${{ steps.baiduwp_version.outputs.VERSION }} | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to DockerHub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Log in to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push the Debian based image | |
id: docker_build_debian | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
file: Dockerfile | |
build-args: | | |
BAIDUWP_VERSION=${{ steps.baiduwp_version.outputs.VERSION }} | |
#DOCKER_GEN_VERSION=${{ steps.docker-gen_version.outputs.VERSION }} | |
platforms: linux/amd64,linux/arm64,linux/arm/v7 | |
push: true | |
#tags: ${{ steps.docker_meta_debian.outputs.tags }} | |
tags: "birdxs/baiduwp,birdxs/baiduwp:latest" | |
labels: ${{ steps.docker_meta_debian.outputs.labels }} | |
- name: Images digests | |
run: echo ${{ steps.docker_build_debian.outputs.digest }} | |