2022-03-07 10:08:17 -05:00
|
|
|
# SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2022-10-02 14:10:32 -04:00
|
|
|
name: Backend / Docker
|
2022-03-07 10:08:17 -05:00
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches: [ develop ]
|
|
|
|
pull_request:
|
|
|
|
branches: [ develop ]
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
build-dev:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2022-10-02 14:10:32 -04:00
|
|
|
- uses: actions/checkout@v3
|
|
|
|
|
2022-03-07 10:08:17 -05:00
|
|
|
- name: Set up Docker Buildx
|
2022-05-07 08:21:51 -04:00
|
|
|
uses: docker/setup-buildx-action@v2
|
2022-03-07 10:08:17 -05:00
|
|
|
|
|
|
|
- name: Login to GHCR
|
2022-05-07 02:19:57 -04:00
|
|
|
uses: docker/login-action@v2
|
2022-03-07 10:08:17 -05:00
|
|
|
with:
|
|
|
|
registry: ghcr.io
|
|
|
|
username: ${{ github.repository_owner }}
|
|
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
|
|
|
|
- name: Build dev image
|
2022-05-07 02:19:55 -04:00
|
|
|
uses: docker/build-push-action@v3
|
2022-03-07 10:08:17 -05:00
|
|
|
with:
|
|
|
|
push: true
|
2022-10-02 14:10:32 -04:00
|
|
|
file: backend/docker/Dockerfile
|
2022-03-07 10:08:17 -05:00
|
|
|
tags: ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}-ci:${{ github.sha }}
|
|
|
|
target: development
|
|
|
|
cache-from: type=gha
|
|
|
|
cache-to: type=gha,mode=max
|
2022-10-02 14:10:32 -04:00
|
|
|
context: .
|
2022-03-07 10:08:17 -05:00
|
|
|
|
|
|
|
sqlite-test:
|
|
|
|
runs-on: ubuntu-latest
|
2022-10-02 14:10:32 -04:00
|
|
|
needs: [ build-dev ]
|
2022-03-07 10:08:17 -05:00
|
|
|
container:
|
|
|
|
image: ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}-ci:${{ github.sha }}
|
|
|
|
steps:
|
|
|
|
- run: cd /usr/src/app && yarn run test
|
|
|
|
|
|
|
|
sqlite-e2e:
|
|
|
|
runs-on: ubuntu-latest
|
2022-10-02 14:10:32 -04:00
|
|
|
needs: [ build-dev ]
|
2022-03-07 10:08:17 -05:00
|
|
|
container:
|
|
|
|
image: ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}-ci:${{ github.sha }}
|
|
|
|
steps:
|
|
|
|
- run: cd /usr/src/app && yarn run test:e2e
|
|
|
|
|
|
|
|
build-prod:
|
|
|
|
runs-on: ubuntu-latest
|
2022-10-02 14:10:32 -04:00
|
|
|
needs: [ sqlite-test, sqlite-e2e ]
|
2022-03-07 10:08:17 -05:00
|
|
|
steps:
|
2022-10-02 14:10:32 -04:00
|
|
|
- uses: actions/checkout@v3
|
|
|
|
|
2022-03-07 10:08:17 -05:00
|
|
|
- name: Generate Docker metadata
|
|
|
|
id: meta
|
2022-05-07 08:21:48 -04:00
|
|
|
uses: docker/metadata-action@v4
|
2022-03-07 10:08:17 -05: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-05-07 08:21:53 -04:00
|
|
|
uses: docker/setup-qemu-action@v2
|
2022-03-07 10:08:17 -05:00
|
|
|
|
|
|
|
- name: Set up Docker Buildx
|
2022-05-07 08:21:51 -04:00
|
|
|
uses: docker/setup-buildx-action@v2
|
2022-03-07 10:08:17 -05:00
|
|
|
|
|
|
|
- name: Login to GHCR
|
|
|
|
if: github.event_name != 'pull_request'
|
2022-05-07 02:19:57 -04:00
|
|
|
uses: docker/login-action@v2
|
2022-03-07 10:08:17 -05:00
|
|
|
with:
|
|
|
|
registry: ghcr.io
|
|
|
|
username: ${{ github.repository_owner }}
|
|
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
|
|
|
|
- name: Build and push
|
2022-05-07 02:19:55 -04:00
|
|
|
uses: docker/build-push-action@v3
|
2022-03-07 10:08:17 -05:00
|
|
|
with:
|
|
|
|
push: ${{ github.event_name != 'pull_request' }}
|
2022-10-02 14:10:32 -04:00
|
|
|
file: backend/docker/Dockerfile
|
2022-03-07 10:08:17 -05:00
|
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
|
|
cache-from: type=gha
|
|
|
|
cache-to: type=gha,mode=max
|
2022-10-02 14:10:32 -04:00
|
|
|
context: .
|