mirror of
https://github.com/xuthus83/pigallery2.git
synced 2024-11-03 21:04:03 +08:00
195 lines
5.7 KiB
YAML
195 lines
5.7 KiB
YAML
name: docker-buildx
|
|
on:
|
|
pull_request:
|
|
branches: master
|
|
push:
|
|
branches: master
|
|
tags:
|
|
- '*.*'
|
|
|
|
jobs:
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
|
|
strategy:
|
|
matrix:
|
|
node-version: [10.x, 12.x, 13.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@v1
|
|
- name: Use Node.js ${{ matrix.node-version }}
|
|
uses: actions/setup-node@v1
|
|
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, build, and test
|
|
run: |
|
|
npm ci
|
|
npm run build --if-present
|
|
npm test
|
|
env:
|
|
MYSQL_HOST: localhost
|
|
MYSQL_USERNAME: root
|
|
MYSQL_PASSWORD: password
|
|
MYSQL_PORT: ${{ job.services.mariadb.ports[3306] }}
|
|
MYSQL_DATABASE: pigallery_test
|
|
PORT: 35000
|
|
CI: true
|
|
|
|
create-release:
|
|
runs-on: [ubuntu-latest]
|
|
needs: [test]
|
|
steps:
|
|
-
|
|
name: Checkout
|
|
uses: actions/checkout@v1
|
|
-
|
|
name: Setup Node.js for use with actions
|
|
uses: actions/setup-node@v1.1.0
|
|
with:
|
|
version: 12
|
|
-
|
|
name: Install Deps
|
|
run: npm install --unsafe-perm
|
|
-
|
|
name: Create Release
|
|
run: npm run create-release -- --skip-opt-packages=ffmpeg,ffprobe --force-opt-packages
|
|
- uses: actions/upload-artifact@v1
|
|
with:
|
|
name: pigallery2-release
|
|
path: release
|
|
build-alpine:
|
|
runs-on: [ubuntu-latest]
|
|
needs: [create-release]
|
|
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@v1
|
|
-
|
|
uses: actions/download-artifact@v1
|
|
with:
|
|
name: pigallery2-release
|
|
-
|
|
name: Set up Docker Buildx
|
|
id: buildx
|
|
uses: crazy-max/ghaction-docker-buildx@v1
|
|
with:
|
|
version: latest
|
|
-
|
|
name: Available platforms
|
|
run: echo ${{ steps.buildx.outputs.platforms }}
|
|
-
|
|
name: Docker login
|
|
run: |
|
|
docker login -u "${DOCKER_REGISTRY_USERNAME}" -p "${DOCKER_REGISTRY_PASSWORD}"
|
|
env:
|
|
DOCKER_REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }}
|
|
DOCKER_REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
|
|
-
|
|
name: Run Buildx alpine
|
|
if: startsWith(steps.vars.outputs.type , 'head')
|
|
run: |
|
|
docker buildx build \
|
|
--platform linux/amd64,linux/arm64,linux/arm/v7 \
|
|
--output "type=image,push=true" \
|
|
--tag bpatrik/pigallery2:nightly-alpine \
|
|
--file docker/alpine/Dockerfile.build .
|
|
- name: Run Buildx alpine for tag
|
|
if: startsWith(steps.vars.outputs.type , 'tag')
|
|
env:
|
|
RELEASE_VERSION: ${{ steps.vars.outputs.tag }}
|
|
run: |
|
|
docker buildx build \
|
|
--platform linux/amd64,linux/arm64,linux/arm/v7 \
|
|
--output "type=image,push=true" \
|
|
--tag bpatrik/pigallery2:nightly-alpine \
|
|
--tag bpatrik/pigallery2:$RELEASE_VERSION-alpine \
|
|
--tag bpatrik/pigallery2:latest-alpine \
|
|
--file docker/alpine/Dockerfile.build .
|
|
-
|
|
name: Docker logout
|
|
run: |
|
|
docker logout
|
|
build-stretch:
|
|
runs-on: [ubuntu-latest]
|
|
needs: [create-release]
|
|
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@v1
|
|
-
|
|
uses: actions/download-artifact@v1
|
|
with:
|
|
name: pigallery2-release
|
|
-
|
|
name: Set up Docker Buildx
|
|
id: buildx
|
|
uses: crazy-max/ghaction-docker-buildx@v1
|
|
with:
|
|
version: latest
|
|
-
|
|
name: Available platforms
|
|
run: echo ${{ steps.buildx.outputs.platforms }}
|
|
-
|
|
name: Docker login
|
|
run: |
|
|
docker login -u "${DOCKER_REGISTRY_USERNAME}" -p "${DOCKER_REGISTRY_PASSWORD}"
|
|
env:
|
|
DOCKER_REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }}
|
|
DOCKER_REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
|
|
-
|
|
name: Run Buildx stretch
|
|
if: startsWith(steps.vars.outputs.type , 'head')
|
|
run: |
|
|
docker buildx build \
|
|
--platform linux/amd64,linux/arm64,linux/arm/v7 \
|
|
--output "type=image,push=true" \
|
|
--tag bpatrik/pigallery2:nightly-stretch \
|
|
--file docker/debian-stretch/Dockerfile.build .
|
|
-
|
|
name: Run Buildx stretch for tag
|
|
if: startsWith(steps.vars.outputs.type , 'tag')
|
|
env:
|
|
RELEASE_VERSION: ${{ steps.vars.outputs.tag }}
|
|
run: |
|
|
docker buildx build \
|
|
--platform linux/amd64,linux/arm64,linux/arm/v7 \
|
|
--output "type=image,push=true" \
|
|
--tag bpatrik/pigallery2:nightly-stretch \
|
|
--tag bpatrik/pigallery2:$RELEASE_VERSION \
|
|
--tag bpatrik/pigallery2:latest \
|
|
--file docker/debian-stretch/Dockerfile.build .
|
|
-
|
|
name: Docker logout
|
|
run: |
|
|
docker logout
|