test #2248
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 And Push Docker Image | |
on: | |
push: | |
branches: | |
- 'master' | |
- 'develop' | |
tags: | |
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 | |
schedule: | |
# 参考 https://jasonet.co/posts/scheduled-actions/ | |
- cron: '00 14 * * *' # GMT 15:00 => 北京时间 23:00 | |
workflow_dispatch: | |
jobs: | |
build: | |
# needs: build-static | |
runs-on: ubuntu-latest | |
permissions: | |
packages: write | |
contents: read | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: pnpm/action-setup@v2 | |
with: | |
version: '8.3.1' | |
- uses: actions/setup-node@v3 | |
with: | |
cache: 'pnpm' | |
- name: Setup timezone | |
uses: zcong1993/setup-timezone@master | |
with: | |
timezone: Asia/Shanghai | |
- name: Login to DockerHub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Login to GHCR | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: | | |
${{ github.repository }} | |
ghcr.io/${{ github.repository }} | |
# generate Docker tags based on the following events/attributes | |
# nightly, master, pr-2, 1.2.3, 1.2, 1 | |
flavor: | | |
latest=false | |
tags: | | |
type=schedule,pattern=nightly | |
type=edge | |
type=ref,event=pr | |
type=ref,event=branch,enable=${{ github.ref != format('refs/heads/{0}', 'master') }} | |
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'master') }} | |
type=semver,pattern={{version}} | |
type=semver,pattern={{major}}.{{minor}} | |
type=semver,pattern={{major}} | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Build and push | |
id: docker_build | |
uses: docker/build-push-action@v3 | |
with: | |
build-args: | | |
MAINTAINER=${{ github.repository_owner }} | |
QL_BRANCH=${{ github.ref_name }} | |
SOURCE_COMMIT=${{ github.sha }} | |
network: host | |
platforms: linux/s390x | |
context: . | |
file: ./docker/Dockerfile | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
cache-from: type=registry,ref=whyour/qinglong:cache | |
cache-to: type=registry,ref=whyour/qinglong:cache,mode=max | |
- name: Image digest | |
run: echo ${{ steps.docker_build.outputs.digest }} |