mirror of
https://github.com/ajnart/homarr.git
synced 2025-12-27 10:49:58 +01:00
73 lines
2.0 KiB
YAML
73 lines
2.0 KiB
YAML
name: Build and publish Docker image
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- v*
|
|
workflow_dispatch:
|
|
|
|
env:
|
|
IMAGE_NAME: mhp
|
|
|
|
jobs:
|
|
# Push image to GitHub Packages.
|
|
# See also https://docs.docker.com/docker-hub/builds/
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/setup-node@v3
|
|
- uses: actions/checkout@v3
|
|
- run: yarn install --frozen-lockfile
|
|
- run: yarn export
|
|
- uses: actions/cache@v2
|
|
id: restore-build
|
|
with:
|
|
path: ./out/
|
|
key: ${{ github.sha }}
|
|
|
|
push:
|
|
runs-on: ubuntu-latest
|
|
needs: [build]
|
|
permissions:
|
|
packages: write
|
|
contents: read
|
|
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
- uses: actions/cache@v2
|
|
id: restore-build
|
|
with:
|
|
path: ./out/
|
|
key: ${{ github.sha }}
|
|
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v2
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v2
|
|
|
|
- name: Build image
|
|
run: docker buildx build --platform linux/arm/v7,linux/amd64,linux/arm64 . --tag $IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}"
|
|
|
|
- name: Log in to registry
|
|
|
|
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin
|
|
- name: Push image
|
|
run: |
|
|
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME
|
|
|
|
# Change all uppercase to lowercase
|
|
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
|
|
# Strip git ref prefix from version
|
|
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
|
|
# Strip "v" prefix from tag name
|
|
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
|
|
# Use Docker `latest` tag convention
|
|
[ "$VERSION" == "master" ] && VERSION=latest
|
|
echo IMAGE_ID=$IMAGE_ID
|
|
echo VERSION=$VERSION
|
|
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
|
|
docker push $IMAGE_ID:$VERSION
|
|
docker tag $IMAGE_NAME $IMAGE_ID:latest
|
|
docker push $IMAGE_ID:latest
|