82 lines
2.3 KiB
YAML
82 lines
2.3 KiB
YAML
name: ci
|
|
on:
|
|
push:
|
|
branches:
|
|
- "*"
|
|
workflow_dispatch:
|
|
env:
|
|
TEST_TAG: ${{ secrets.DOCKERHUB_USERNAME }}/xiaomusic:${{ github.ref_name }}
|
|
jobs:
|
|
build-test-publish:
|
|
runs-on: ubuntu-latest
|
|
if: github.event_name != 'pull_request'
|
|
strategy:
|
|
matrix:
|
|
platform: [linux/amd64, linux/arm64, linux/arm/v7]
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v3
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Login to Docker Hub
|
|
uses: docker/login-action@v3
|
|
with:
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
- name: Set tags name
|
|
id: gen_tag_name
|
|
env:
|
|
IMAGE_NAME: ${{ env.TEST_TAG }}
|
|
PLATFORM_NAME: ${{ matrix.platform }}
|
|
run: |
|
|
echo "TAGNAME=${IMAGE_NAME}-${PLATFORM_NAME//\//-}" >> $GITHUB_ENV
|
|
|
|
- name: Build Docker image
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
platforms: ${{ matrix.platform }}
|
|
context: .
|
|
file: ./Dockerfile
|
|
push: false
|
|
load: true
|
|
tags: ${{ env.TAGNAME }}
|
|
cache-from: type=local,src=/tmp/.buildx-cache
|
|
cache-to: type=local,dest=/tmp/.buildx-cache-new
|
|
|
|
- name: Test Docker image
|
|
run: docker run --rm ${{ env.TAGNAME }} -h
|
|
|
|
- name: Publish to Docker Hub
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
platforms: linux/amd64, linux/arm64, linux/arm/v7
|
|
context: .
|
|
file: ./Dockerfile
|
|
push: true
|
|
tags: ${{ env.TEST_TAG }}
|
|
cache-from: type=local,src=/tmp/.buildx-cache
|
|
cache-to: type=local,dest=/tmp/.buildx-cache-new
|
|
|
|
publish-readme:
|
|
runs-on: ubuntu-latest
|
|
needs: build-test-publish
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Login to Docker Hub
|
|
uses: docker/login-action@v3
|
|
with:
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
- name: Docker Hub Description
|
|
uses: peter-evans/dockerhub-description@v4
|
|
with:
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
repository: hanxi/xiaomusic
|