2022-07-25 14:28:45 -04:00
|
|
|
# SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2022-11-11 04:55:08 -05:00
|
|
|
name: Frontend / build docker image
|
2022-07-25 14:28:45 -04:00
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
2022-11-11 04:55:08 -05:00
|
|
|
branches: [ develop ]
|
|
|
|
|
|
|
|
defaults:
|
|
|
|
run:
|
|
|
|
working-directory: frontend
|
|
|
|
|
|
|
|
concurrency:
|
2022-12-05 12:40:59 -05:00
|
|
|
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.job }}
|
2022-11-11 04:55:08 -05:00
|
|
|
cancel-in-progress: true
|
2022-07-25 14:28:45 -04:00
|
|
|
|
|
|
|
jobs:
|
2022-11-11 04:55:08 -05:00
|
|
|
changes:
|
|
|
|
name: Check for frontend changes
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
permissions:
|
|
|
|
pull-requests: read
|
|
|
|
outputs:
|
2022-11-21 11:24:36 -05:00
|
|
|
changed: ${{ github.event_name == 'push' || steps.changed.outputs.files }}
|
2022-11-11 04:55:08 -05:00
|
|
|
steps:
|
2022-11-20 16:16:54 -05:00
|
|
|
- uses: actions/checkout@v3
|
2022-11-21 11:24:36 -05:00
|
|
|
if: github.event_name != 'push'
|
|
|
|
|
2022-11-11 04:55:08 -05:00
|
|
|
- name: Check for frontend file changes
|
2022-11-21 11:24:36 -05:00
|
|
|
if: github.event_name != 'push'
|
2022-11-11 04:55:08 -05:00
|
|
|
uses: dorny/paths-filter@v2
|
|
|
|
id: changed
|
|
|
|
with:
|
|
|
|
filters: |
|
|
|
|
files:
|
2022-12-04 16:41:39 -05:00
|
|
|
- 'commons/**'
|
2022-11-11 04:55:08 -05:00
|
|
|
- 'frontend/**'
|
|
|
|
- '.github/**'
|
|
|
|
- '.yarn/**'
|
|
|
|
|
2022-07-25 14:28:45 -04:00
|
|
|
build:
|
2022-11-11 04:55:08 -05:00
|
|
|
needs: changes
|
2022-07-25 14:28:45 -04:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2022-11-20 16:56:42 -05:00
|
|
|
- uses: actions/checkout@v3
|
|
|
|
if: needs.changes.outputs.changed == 'true'
|
|
|
|
|
2022-07-25 14:28:45 -04:00
|
|
|
- name: Generate Docker metadata
|
2022-11-11 04:55:08 -05:00
|
|
|
if: needs.changes.outputs.changed == 'true'
|
2022-07-25 14:28:45 -04:00
|
|
|
id: meta
|
|
|
|
uses: docker/metadata-action@v4
|
|
|
|
with:
|
|
|
|
images: ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}
|
|
|
|
tags: |
|
|
|
|
type=ref,event=branch
|
|
|
|
type=semver,pattern={{version}}
|
|
|
|
type=semver,pattern={{major}}.{{minor}}
|
|
|
|
type=semver,pattern={{major}}
|
|
|
|
|
|
|
|
- name: Set up QEMU
|
2022-11-11 04:55:08 -05:00
|
|
|
if: needs.changes.outputs.changed == 'true'
|
2022-07-25 14:28:45 -04:00
|
|
|
uses: docker/setup-qemu-action@v2
|
|
|
|
|
|
|
|
- name: Set up Docker Buildx
|
2022-11-11 04:55:08 -05:00
|
|
|
if: needs.changes.outputs.changed == 'true'
|
2022-07-25 14:28:45 -04:00
|
|
|
uses: docker/setup-buildx-action@v2
|
|
|
|
|
|
|
|
- name: Login to GHCR
|
2022-11-11 04:55:08 -05:00
|
|
|
if: github.event_name != 'pull_request' && needs.changes.outputs.changed == 'true'
|
2022-07-25 14:28:45 -04:00
|
|
|
uses: docker/login-action@v2
|
|
|
|
with:
|
|
|
|
registry: ghcr.io
|
|
|
|
username: ${{ github.repository_owner }}
|
|
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
|
|
|
|
- name: Build and push
|
2022-11-11 04:55:08 -05:00
|
|
|
if: needs.changes.outputs.changed == 'true'
|
2022-07-25 14:28:45 -04:00
|
|
|
uses: docker/build-push-action@v3
|
|
|
|
with:
|
2022-07-31 12:13:54 -04:00
|
|
|
push: true
|
2022-11-02 11:24:45 -04:00
|
|
|
file: frontend/docker/Dockerfile
|
2022-07-25 14:28:45 -04:00
|
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
|
|
cache-from: type=gha
|
|
|
|
cache-to: type=gha,mode=max
|
2022-11-11 04:55:08 -05:00
|
|
|
context: .
|
2022-08-30 06:28:53 -04:00
|
|
|
build-args: |
|
|
|
|
BUILD_VERSION=${{ github.event.head_commit.id }}
|