summaryrefslogtreecommitdiff
path: root/.gitea/workflows/build.yml
blob: 7aae92dbb63b2de814a75e2510efcc71fd841708 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json

name: build

on:
  push:
    branches:
      - "master"
  workflow_dispatch: {}

defaults:
  run:
    shell: sh

jobs:
  phpdoc:
    runs-on: alpine-3.16
    steps:
    - uses: https://gitea.com/actions/checkout@v3

    - name: phpdoc
      run: php81 /phpDocumentor.phar -d classes -d include -t phpdoc --visibility=public

    - name: prepare ssh
      run: |
        mkdir -p ~/.ssh
        echo "${{ secrets.APK_DEPLOY_SSH_KEY }}" | tr -d \\r > ~/.ssh/id_ed25519
        chmod 600 ~/.ssh/id_ed25519

    - name: upload results
      run: rsync -av -e 'ssh -o StrictHostKeyChecking=no' phpdoc/ ${{ secrets.APK_DEPLOY_USER }}@${{ secrets.APK_DEPLOY_HOST }}:phpdoc/

  build:
    runs-on: alpine-3.16
    steps:
    - uses: https://gitea.com/actions/checkout@v3

    - name: eslint
      run: npx eslint js plugins

    - run: rm -rf node_modules

    - name: phpunit
      run: php81 ./vendor/bin/phpunit

    - name: calculate cache key hash
      uses: actions/[email protected]
      id: cache-hash
      with:
        patterns: |
          classes/*.php
          include/*.php
          plugins/**/*.php

    - name: phpstan
      run: php81 -d memory_limit=-1 ./vendor/bin/phpstan --memory-limit=2G

    - name: setup qemu
      uses: https://github.com/docker/setup-qemu-action@v2

    - name: setup buildx
      uses: https://github.com/docker/setup-buildx-action@v2

    - name: login to registry
      uses: https://github.com/docker/login-action@v2
      with:
        registry: ${{ secrets.REGISTRY_HOST }}
        username: ${{ secrets.REGISTRY_USER }}
        password: ${{ secrets.REGISTRY_PASSWORD }}

    - name: login to docker hub
      uses: https://github.com/docker/login-action@v2
      with:
        username: ${{ secrets.DOCKER_HUB_USER }}
        password: ${{ secrets.DOCKER_HUB_TOKEN }}

    - name: get docker meta for web-nginx
      id: meta_web_nginx
      uses: https://github.com/docker/metadata-action@v4
      with:
        images: |
          ${{ secrets.REGISTRY_HOST }}/cthulhoo/ttrss-web-nginx
          cthulhoo/ttrss-web-nginx
        tags: |
          type=sha,prefix={{ date 'YY.MM-' tz='UTC'}}
          type=raw,value=latest,enable={{ is_default_branch }}

    - name: build web-nginx image
      uses: https://github.com/docker/build-push-action@v4
      with:
        push: true
        platforms: linux/amd64,linux/arm64,linux/arm/v7
        context: .docker/web-nginx
        tags: ${{ steps.meta_web_nginx.outputs.tags }}
        labels: ${{ steps.meta_web_nginx.outputs.labels }}
        provenance: false
        cache-from: type=registry,ref=${{ secrets.REGISTRY_HOST }}/cthulhoo/ttrss-web-nginx:latest
        cache-to: type=inline

    - name: get docker meta for app
      id: meta_app
      uses: https://github.com/docker/metadata-action@v4
      with:
        images: |
          ${{ secrets.REGISTRY_HOST }}/cthulhoo/ttrss-fpm-pgsql-static
          cthulhoo/ttrss-fpm-pgsql-static
        tags: |
          type=sha,prefix={{ date 'YY.MM-' tz='UTC'}}
          type=raw,value=latest,enable={{ is_default_branch }}

    - name: build app image
      uses: https://github.com/docker/build-push-action@v4
      with:
        push: true
        platforms: linux/amd64,linux/arm64,linux/arm/v7
        context: .docker/app
        build-contexts:
          app-src=.
        tags: ${{ steps.meta_app.outputs.tags }}
        labels: ${{ steps.meta_app.outputs.labels }}
        provenance: false
        cache-from: type=registry,ref=${{ secrets.REGISTRY_HOST }}/cthulhoo/ttrss-fpm-pgsql-static:latest
        cache-to: type=inline