xiaomusic/.github/workflows/ci.yml

80 lines
2.3 KiB
YAML
Raw Normal View History

2024-02-04 06:11:40 +00:00
name: ci
on:
push:
branches:
- "*"
2024-02-04 06:11:40 +00:00
workflow_dispatch:
env:
TEST_TAG: ${{ secrets.DOCKERHUB_USERNAME }}/xiaomusic:${{ github.ref_name }}
2024-02-04 06:11:40 +00:00
jobs:
2024-10-30 03:07:55 +00:00
build-test-publish:
2024-02-04 06:11:40 +00:00
runs-on: ubuntu-latest
if: github.event_name != 'pull_request'
2024-10-30 01:19:41 +00:00
strategy:
matrix:
platform: [linux/amd64, linux/arm64, linux/arm/v7]
2024-02-04 06:11:40 +00:00
steps:
2024-10-30 03:11:10 +00:00
- uses: actions/checkout@v4
2024-10-30 01:19:41 +00:00
2024-02-04 06:11:40 +00:00
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
2024-02-04 06:11:40 +00:00
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
2024-02-04 06:11:40 +00:00
- name: Login to Docker Hub
uses: docker/login-action@v3
2024-02-04 06:11:40 +00:00
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
2024-10-30 02:05:32 +00:00
- name: Set tags name
2024-10-30 02:23:26 +00:00
id: gen_tag_name
2024-10-30 02:05:32 +00:00
env:
2024-10-30 02:39:20 +00:00
IMAGE_NAME: ${{ env.TEST_TAG }}
PLATFORM_NAME: ${{ matrix.platform }}
2024-10-30 02:23:26 +00:00
run: |
2024-10-30 02:45:41 +00:00
echo "TAGNAME=${IMAGE_NAME}-${PLATFORM_NAME//\//-}" >> $GITHUB_ENV
2024-10-30 02:05:32 +00:00
2024-10-30 01:19:41 +00:00
- name: Build Docker image
uses: docker/build-push-action@v6
with:
2024-10-30 01:19:41 +00:00
platforms: ${{ matrix.platform }}
context: .
2024-10-23 07:31:04 +00:00
push: false
load: true
2024-10-30 02:05:32 +00:00
tags: ${{ env.TAGNAME }}
2024-10-30 04:32:56 +00:00
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
2024-10-30 01:19:41 +00:00
- name: Test Docker image
2024-10-30 02:05:32 +00:00
run: docker run --rm ${{ env.TAGNAME }} -h
2024-10-30 03:07:55 +00:00
- name: Publish to Docker Hub
uses: docker/build-push-action@v6
with:
2024-10-30 04:34:15 +00:00
platforms: linux/amd64,linux/arm64,linux/arm/v7
2024-10-30 03:07:55 +00:00
context: .
push: true
tags: ${{ env.TEST_TAG }}
2024-10-30 04:32:56 +00:00
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
2024-10-30 03:07:55 +00:00
publish-readme:
2024-10-30 01:19:41 +00:00
runs-on: ubuntu-latest
2024-10-30 03:09:32 +00:00
needs: build-test-publish
2024-10-30 01:19:41 +00:00
steps:
2024-10-30 03:29:06 +00:00
- uses: actions/checkout@v4
2024-10-30 01:19:41 +00:00
- name: Login to Docker Hub
uses: docker/login-action@v3
2024-02-04 06:11:40 +00:00
with:
2024-10-30 01:19:41 +00:00
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
2024-10-23 07:31:04 +00:00
2024-07-05 13:22:36 +00:00
- name: Docker Hub Description
uses: peter-evans/dockerhub-description@v4
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
2024-07-05 14:15:14 +00:00
repository: hanxi/xiaomusic