1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2024-11-03 21:04:03 +08:00
pigallery2/.github/workflows/build.yml
2022-04-25 18:09:06 +02:00

173 lines
5.4 KiB
YAML

name: docker-buildx
on:
pull_request:
branches:
- master
- experimental
push:
branches:
- '**'
tags:
- '*.*'
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x]
services:
mariadb:
image: mariadb:latest
ports:
- 3306
env:
MYSQL_USER: user
MYSQL_PASSWORD: password
MYSQL_DATABASE: pigallery_test
MYSQL_ROOT_PASSWORD: password
options: --health-cmd="mysqladmin ping" --health-interval=5s --health-timeout=2s --health-retries=3
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- name: Verify MariaDB connection
env:
PORT: ${{ job.services.mariadb.ports[3306] }}
run: |
while ! mysqladmin ping -h"127.0.0.1" -P"$PORT" --silent; do
sleep 1
done
- name: npm install and build
run: |
npm ci
npm run build
- name: lint
run: |
npm run lint
- name: test
run: |
npm test
env:
MYSQL_HOST: localhost
MYSQL_USERNAME: root
MYSQL_PASSWORD: password
MYSQL_PORT: ${{ job.services.mariadb.ports[3306] }}
PORT: 35000
CI: true
create-release:
runs-on: [ubuntu-latest]
needs: [test]
steps:
-
name: Checkout
uses: actions/checkout@v2
-
name: Setup Node.js for use with actions
uses: actions/setup-node@v2
with:
node-version: 12
-
name: Install Deps
run: npm install --unsafe-perm
-
name: Create Release
run: npm run create-release -- --skip-opt-packages=ffmpeg-static,ffprobe-static --force-opt-packages
- uses: actions/upload-artifact@v2
with:
name: pigallery2-release
path: release
build-dockerx:
runs-on: [ ubuntu-latest ]
needs: [ create-release ]
strategy:
matrix:
container: [alpine, debian-buster, debian-bullseye ]
include:
- container: alpine
platforms: linux/amd64,linux/arm64
- container: debian-buster
platforms: linux/amd64,linux/arm64,linux/arm/v7
- container: debian-bullseye
platforms: linux/amd64,linux/arm64,linux/arm/v7
steps:
- name: Set tag
id: vars
run: echo ::set-output name=tag::$(echo ${GITHUB_REF:10}) && echo ::set-output name=type::$(echo ${GITHUB_REF:5})
- name: Checkout
uses: actions/checkout@v2
- uses: actions/download-artifact@v2
with:
name: pigallery2-release
path: pigallery2-release
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Build docker
uses: docker/build-push-action@v2
with:
context: .
file: docker/${{ matrix.container }}/Dockerfile.build
platforms: ${{ matrix.platforms }}
- name: Push experimental
if: ${{ github.ref == 'refs/heads/experimental' }}
uses: docker/build-push-action@v2
with:
context: .
file: docker/${{ matrix.container }}/Dockerfile.build
platforms: ${{ matrix.platforms }}
push: true
tags: bpatrik/pigallery2:experimental-${{ matrix.container }}
- name: Push nightly on new master commit
if: ${{ startsWith(steps.vars.outputs.type , 'head') && !github.event.issue.pull_request && github.ref == 'refs/heads/master' }}
uses: docker/build-push-action@v2
with:
context: .
file: docker/${{ matrix.container }}/Dockerfile.build
platforms: ${{ matrix.platforms }}
push: true
tags: bpatrik/pigallery2:nightly-${{ matrix.container }}
- name: Push release on new Tag
if: ${{ startsWith(steps.vars.outputs.type , 'tag') && !github.event.issue.pull_request && matrix.container != 'debian-buster'}}
uses: docker/build-push-action@v2
with:
context: .
file: docker/${{ matrix.container }}/Dockerfile.build
platforms: ${{ matrix.platforms }}
push: true
tags: |
bpatrik/pigallery2:nightly-${{ matrix.container }}
bpatrik/pigallery2:${{ steps.vars.outputs.tag }}-${{ matrix.container }}
bpatrik/pigallery2:latest-${{ matrix.container }}
- name: Push latest on new Tag
if: ${{ startsWith(steps.vars.outputs.type , 'tag') && !github.event.issue.pull_request && matrix.container == 'debian-buster'}}
uses: docker/build-push-action@v2
with:
context: .
file: docker/${{ matrix.container }}/Dockerfile.build
platforms: ${{ matrix.platforms }}
push: true
tags: |
bpatrik/pigallery2:nightly-${{ matrix.container }}
bpatrik/pigallery2:${{ steps.vars.outputs.tag }}-${{ matrix.container }}
bpatrik/pigallery2:latest-${{ matrix.container }}
bpatrik/pigallery2:${{ steps.vars.outputs.tag }}
bpatrik/pigallery2:latest