2022-07-25 18:28:45 +00:00
|
|
|
# SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2022-11-11 09:55:08 +00:00
|
|
|
name: Frontend / build docker image
|
2022-07-25 18:28:45 +00:00
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
2022-11-11 09:55:08 +00:00
|
|
|
branches: [ develop ]
|
|
|
|
|
|
|
|
defaults:
|
|
|
|
run:
|
|
|
|
working-directory: frontend
|
|
|
|
|
|
|
|
concurrency:
|
2022-12-05 17:40:59 +00:00
|
|
|
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.job }}
|
2022-11-11 09:55:08 +00:00
|
|
|
cancel-in-progress: true
|
2022-07-25 18:28:45 +00:00
|
|
|
|
2023-01-08 22:11:23 +00:00
|
|
|
permissions:
|
|
|
|
contents: read
|
|
|
|
|
2022-07-25 18:28:45 +00:00
|
|
|
jobs:
|
2022-11-11 09:55:08 +00:00
|
|
|
changes:
|
|
|
|
name: Check for frontend changes
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
permissions:
|
|
|
|
pull-requests: read
|
|
|
|
outputs:
|
2022-11-21 16:24:36 +00:00
|
|
|
changed: ${{ github.event_name == 'push' || steps.changed.outputs.files }}
|
2022-11-11 09:55:08 +00:00
|
|
|
steps:
|
2023-01-08 22:11:23 +00:00
|
|
|
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
|
2022-11-21 16:24:36 +00:00
|
|
|
if: github.event_name != 'push'
|
|
|
|
|
2022-11-11 09:55:08 +00:00
|
|
|
- name: Check for frontend file changes
|
2022-11-21 16:24:36 +00:00
|
|
|
if: github.event_name != 'push'
|
2023-01-08 22:11:23 +00:00
|
|
|
uses: dorny/paths-filter@4512585405083f25c027a35db413c2b3b9006d50 # v2.11.1
|
2022-11-11 09:55:08 +00:00
|
|
|
id: changed
|
|
|
|
with:
|
|
|
|
filters: |
|
|
|
|
files:
|
2022-12-04 21:41:39 +00:00
|
|
|
- 'commons/**'
|
2022-11-11 09:55:08 +00:00
|
|
|
- 'frontend/**'
|
|
|
|
- '.github/**'
|
|
|
|
- '.yarn/**'
|
|
|
|
|
2022-07-25 18:28:45 +00:00
|
|
|
build:
|
2022-11-11 09:55:08 +00:00
|
|
|
needs: changes
|
2022-07-25 18:28:45 +00:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2023-01-08 22:11:23 +00:00
|
|
|
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
|
2022-11-20 21:56:42 +00:00
|
|
|
if: needs.changes.outputs.changed == 'true'
|
|
|
|
|
2022-07-25 18:28:45 +00:00
|
|
|
- name: Generate Docker metadata
|
2022-11-11 09:55:08 +00:00
|
|
|
if: needs.changes.outputs.changed == 'true'
|
2022-07-25 18:28:45 +00:00
|
|
|
id: meta
|
2023-01-08 22:11:23 +00:00
|
|
|
uses: docker/metadata-action@57396166ad8aefe6098280995947635806a0e6ea # v4.1.1
|
2022-07-25 18:28:45 +00:00
|
|
|
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 09:55:08 +00:00
|
|
|
if: needs.changes.outputs.changed == 'true'
|
2023-01-08 22:11:23 +00:00
|
|
|
uses: docker/setup-qemu-action@e81a89b1732b9c48d79cd809d8d81d79c4647a18 # v2.1.0
|
2022-07-25 18:28:45 +00:00
|
|
|
|
|
|
|
- name: Set up Docker Buildx
|
2022-11-11 09:55:08 +00:00
|
|
|
if: needs.changes.outputs.changed == 'true'
|
2023-01-08 22:11:23 +00:00
|
|
|
uses: docker/setup-buildx-action@8c0edbc76e98fa90f69d9a2c020dcb50019dc325 # v2.2.1
|
2022-07-25 18:28:45 +00:00
|
|
|
|
|
|
|
- name: Login to GHCR
|
2022-11-11 09:55:08 +00:00
|
|
|
if: github.event_name != 'pull_request' && needs.changes.outputs.changed == 'true'
|
2023-01-08 22:11:23 +00:00
|
|
|
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a # v2.1.0
|
2022-07-25 18:28:45 +00:00
|
|
|
with:
|
|
|
|
registry: ghcr.io
|
|
|
|
username: ${{ github.repository_owner }}
|
|
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
|
|
|
|
- name: Build and push
|
2022-11-11 09:55:08 +00:00
|
|
|
if: needs.changes.outputs.changed == 'true'
|
2023-01-08 22:11:23 +00:00
|
|
|
uses: docker/build-push-action@c56af957549030174b10d6867f20e78cfd7debc5 # v3.2.0
|
2022-07-25 18:28:45 +00:00
|
|
|
with:
|
2022-07-31 16:13:54 +00:00
|
|
|
push: true
|
2022-11-02 15:24:45 +00:00
|
|
|
file: frontend/docker/Dockerfile
|
2022-07-25 18:28:45 +00:00
|
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
|
|
cache-from: type=gha
|
|
|
|
cache-to: type=gha,mode=max
|
2022-11-11 09:55:08 +00:00
|
|
|
context: .
|
2022-08-30 10:28:53 +00:00
|
|
|
build-args: |
|
|
|
|
BUILD_VERSION=${{ github.event.head_commit.id }}
|