97 lines
2.6 KiB
YAML
97 lines
2.6 KiB
YAML
name: Docker
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
- 4.x
|
|
|
|
env:
|
|
php-version: '8.2'
|
|
node-version: 20
|
|
|
|
concurrency:
|
|
group: Docker ${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
docker-run:
|
|
runs-on: ubuntu-latest
|
|
name: Docker build developpment
|
|
|
|
strategy:
|
|
fail-fast: false
|
|
|
|
steps:
|
|
- name: Checkout sources
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Docker meta
|
|
id: docker_meta
|
|
uses: crazy-max/ghaction-docker-meta@v4
|
|
with:
|
|
images: ghcr.io/monicahq/monica
|
|
tags: |
|
|
type=sha
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v2
|
|
|
|
- name: Login to GitHub container registry
|
|
uses: docker/login-action@v2
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ secrets.CR_USER }}
|
|
password: ${{ secrets.CR_PAT }}
|
|
|
|
# Composer
|
|
- name: Get Composer Cache Directory
|
|
id: composer-cache
|
|
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
|
|
- name: Cache composer files
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: ${{ steps.composer-cache.outputs.dir }}
|
|
key: ${{ runner.os }}-composer-${{ env.php-version }}-${{ hashFiles('**/composer.lock') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-composer-${{ env.php-version }}-${{ hashFiles('**/composer.lock') }}
|
|
${{ runner.os }}-composer-${{ env.php-version }}
|
|
${{ runner.os }}-composer-
|
|
|
|
# Yarn
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v3
|
|
with:
|
|
node-version: ${{ env.node-version }}
|
|
- name: Get yarn cache directory path
|
|
id: yarn-cache
|
|
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
|
|
- name: Cache yarn files
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: ${{ steps.yarn-cache.outputs.dir }}
|
|
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
|
${{ runner.os }}-yarn-
|
|
|
|
# Install
|
|
- name: Install
|
|
run: scripts/docker/build.sh --skip-build $GITHUB_SHA
|
|
|
|
# Build docker
|
|
- name: Docker build
|
|
id: docker_build
|
|
uses: docker/build-push-action@v3
|
|
with:
|
|
push: true
|
|
tags: ${{ steps.docker_meta.outputs.tags }}
|
|
labels: ${{ steps.docker_meta.outputs.labels }}
|
|
file: scripts/docker/Dockerfile
|
|
context: .
|
|
|
|
- name: Image digest
|
|
run: echo ${{ steps.docker_build.outputs.digest }}
|