mirror of
https://github.com/icereed/paperless-gpt.git
synced 2025-03-12 21:08:00 -05:00
171 lines
No EOL
5.3 KiB
YAML
171 lines
No EOL
5.3 KiB
YAML
name: Build and Push Docker Images
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
tags:
|
|
- 'v*.*.*'
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
|
|
jobs:
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
go-version: 1.22
|
|
|
|
- name: Install mupdf
|
|
run: sudo apt-get install -y mupdf
|
|
|
|
- name: Set library path
|
|
run: echo "/usr/lib" | sudo tee -a /etc/ld.so.conf.d/mupdf.conf && sudo ldconfig
|
|
|
|
- name: Install dependencies
|
|
run: go mod download
|
|
|
|
- name: Run Go tests
|
|
run: go test ./...
|
|
|
|
- name: Set up Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 20
|
|
|
|
- name: Cache npm dependencies
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: ~/.npm
|
|
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-node-
|
|
|
|
- name: Install frontend dependencies
|
|
run: npm install
|
|
working-directory: web-app
|
|
|
|
- name: Run frontend tests
|
|
run: npm test
|
|
working-directory: web-app
|
|
|
|
build-amd64:
|
|
runs-on: ubuntu-latest
|
|
needs: test
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Log in to Docker Hub
|
|
if: ${{ github.event_name != 'pull_request' }}
|
|
uses: docker/login-action@v3
|
|
with:
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
|
|
- name: Set Docker tags
|
|
id: set_tags
|
|
run: |
|
|
echo "TAGS=icereed/paperless-gpt:unreleased-amd64" >> $GITHUB_ENV
|
|
if [[ "${GITHUB_REF}" == "refs/heads/main" ]]; then
|
|
echo "TAGS=icereed/paperless-gpt:unreleased-amd64" >> $GITHUB_ENV
|
|
elif [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then
|
|
VERSION=${GITHUB_REF#refs/tags/}
|
|
echo "TAGS=icereed/paperless-gpt:${VERSION}-amd64" >> $GITHUB_ENV
|
|
fi
|
|
|
|
- name: Build and push AMD64 image
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
platforms: linux/amd64
|
|
push: ${{ github.event_name != 'pull_request' }}
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|
|
tags: ${{ env.TAGS }}
|
|
build-args: |
|
|
VERSION=${{ github.ref_type == 'tag' && github.ref_name || github.sha }}
|
|
COMMIT=${{ github.sha }}
|
|
BUILD_DATE=${{ github.event.repository.pushed_at }}
|
|
|
|
build-arm64:
|
|
runs-on: ubuntu-24.04-arm
|
|
needs: test
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Log in to Docker Hub
|
|
if: ${{ github.event_name != 'pull_request' }}
|
|
uses: docker/login-action@v3
|
|
with:
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
|
|
- name: Set Docker tags
|
|
id: set_tags
|
|
run: |
|
|
echo "TAGS=icereed/paperless-gpt:unreleased-arm64" >> $GITHUB_ENV
|
|
if [[ "${GITHUB_REF}" == "refs/heads/main" ]]; then
|
|
echo "TAGS=icereed/paperless-gpt:unreleased-arm64" >> $GITHUB_ENV
|
|
elif [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then
|
|
VERSION=${GITHUB_REF#refs/tags/}
|
|
echo "TAGS=icereed/paperless-gpt:${VERSION}-arm64" >> $GITHUB_ENV
|
|
fi
|
|
|
|
- name: Build and push ARM64 image
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
platforms: linux/arm64
|
|
push: ${{ github.event_name != 'pull_request' }}
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|
|
tags: ${{ env.TAGS }}
|
|
build-args: |
|
|
VERSION=${{ github.ref_type == 'tag' && github.ref_name || github.sha }}
|
|
COMMIT=${{ github.sha }}
|
|
BUILD_DATE=${{ github.event.repository.pushed_at }}
|
|
|
|
merge-manifests:
|
|
needs: [build-amd64, build-arm64]
|
|
runs-on: ubuntu-latest
|
|
if: github.event_name != 'pull_request'
|
|
steps:
|
|
- name: Log in to Docker Hub
|
|
uses: docker/login-action@v3
|
|
with:
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
|
|
- name: Create and push manifest
|
|
run: |
|
|
if [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then
|
|
VERSION=${GITHUB_REF#refs/tags/}
|
|
docker manifest create icereed/paperless-gpt:${VERSION} --amend \
|
|
icereed/paperless-gpt:${VERSION}-amd64 \
|
|
icereed/paperless-gpt:${VERSION}-arm64
|
|
docker manifest push --purge icereed/paperless-gpt:${VERSION}
|
|
|
|
docker manifest create icereed/paperless-gpt:latest --amend \
|
|
icereed/paperless-gpt:${VERSION}-amd64 \
|
|
icereed/paperless-gpt:${VERSION}-arm64
|
|
docker manifest push --purge icereed/paperless-gpt:latest
|
|
else
|
|
docker manifest create icereed/paperless-gpt:unreleased --amend \
|
|
icereed/paperless-gpt:unreleased-amd64 \
|
|
icereed/paperless-gpt:unreleased-arm64
|
|
docker manifest push --purge icereed/paperless-gpt:unreleased
|
|
fi |