Files
composite-actions/.github/workflows/docker-build-push.yml

59 lines
2.2 KiB
YAML

on:
pull_request:
paths:
- "docker-build-push/**"
- ".github/workflows/docker-build-push.yml"
push:
paths:
- "docker-build-push/**"
- ".github/workflows/docker-build-push.yml"
env:
TZ: Asia/Shanghai
jobs:
job:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-15] # https://docs.github.com/zh/actions/using-github-hosted-runners/using-github-hosted-runners/about-github-hosted-runners#用于公共存储库的-github-托管的标准运行器
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@main
- uses: yanhao98/semantic-release-action@main
id: semantic
- name: Login to Docker Hub
if: steps.semantic.outputs.next_release_published == 'true'
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry
if: steps.semantic.outputs.next_release_published == 'true'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: yanhao98/composite-actions/docker-build-push@main
# if: steps.semantic.outputs.next_release_published == 'true'
id: docker-build-push
with:
build_file: ./Dockerfile.test
build_platforms: linux/amd64,linux/arm64
build_push: ${{ matrix.os == 'ubuntu-latest' && steps.semantic.outputs.next_release_published == 'true' }}
build_load: false
metadata_images: |
docker.io/${{ vars.DOCKERHUB_USERNAME }}/docker-example
ghcr.io/${{ github.repository }}
metadata_tags: |
type=semver,pattern={{version}},value=${{ steps.semantic.outputs.next_release_version }}
type=semver,pattern={{major}}.{{minor}},value=${{ steps.semantic.outputs.next_release_version }}
type=semver,pattern={{major}},value=${{ steps.semantic.outputs.next_release_version }}
# - name: Check Docker image
# run: |
# set -x;
# docker images;
# docker run --rm ${{ steps.docker-build-push.outputs.imageid }} whoami;