xiaomusic/.github/workflows/ci.yml

90 lines
2.9 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:
build-image:
runs-on: ubuntu-latest
# run unless event type is pull_request
if: github.event_name != 'pull_request'
steps:
- uses: actions/checkout@v3
- 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-23 07:31:04 +00:00
# We have to build each platform separately because when using multi-arch
# builds, only one platform is being loaded into the cache. This would
# prevent us from testing the other platforms.
- name: Build Docker image (linux/amd64)
uses: docker/build-push-action@v6
with:
2024-10-23 07:31:04 +00:00
platforms: linux/amd64
context: .
2024-10-23 07:31:04 +00:00
push: false
load: true
2024-10-23 07:31:04 +00:00
tags: ${{ env.TEST_TAG }}-linux-amd64
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
2024-10-23 07:31:04 +00:00
- name: Build Docker image (linux/arm64)
uses: docker/build-push-action@v6
with:
platforms: linux/arm64
context: .
push: false
load: true
tags: ${{ env.TEST_TAG }}-linux-arm64
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
2024-10-23 07:31:04 +00:00
- name: Build Docker image (linux/arm/v7)
uses: docker/build-push-action@v6
2024-02-04 06:11:40 +00:00
with:
2024-10-23 07:31:04 +00:00
platforms: linux/arm/v7
2024-02-04 06:11:40 +00:00
context: .
2024-10-23 07:31:04 +00:00
push: false
load: true
tags: ${{ env.TEST_TAG }}-linux-arm-v7
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
# We test all the images on amd64 host here. This uses QEMU to emulate
# the other platforms.
- run: docker run --rm ${{ TEST_TAG }}-linux-amd64 --version
- run: docker run --rm ${{ TEST_TAG }}-linux-arm-v7 --version
- run: docker run --rm ${{ TEST_TAG }}-linux-arm64-v8 --version
# This will only push the previously built images.
- name: Publish to Docker Hub
uses: docker/build-push-action@v6
with:
2024-07-14 10:27:35 +00:00
platforms: linux/amd64,linux/arm64,linux/arm/v7
2024-10-23 07:31:04 +00:00
context: .
2024-02-04 06:11:40 +00:00
push: true
tags: ${{ env.TEST_TAG }}
2024-10-23 07:31:04 +00:00
cache-from: type=local,src=/tmp/.buildx-cache-new
cache-to: type=local,dest=/tmp/.buildx-cache-new
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