summaryrefslogtreecommitdiff
path: root/.gitea/workflows/build.yml
blob: b1784a95ee461bba43b15eade0b16c8266904a1d (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
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json

name: build

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

defaults:
  run:
    shell: sh

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

    - name: eslint
      run: npx eslint js

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

    - run: echo REPO_TIMESTAMP=$(git --git-dir '.git' --no-pager log --pretty='%ct' -n1 HEAD) >> $GITHUB_ENV
    - run: echo REPO_COMMIT=$(git --git-dir '.git' --no-pager log --pretty='%h' -n1 HEAD) >> $GITHUB_ENV
    - run: echo REPO_COMMIT_FULL=$(git --git-dir '.git' --no-pager log --pretty='%H' -n1 HEAD) >> $GITHUB_ENV
    - run: echo BUILD_TAG=$(date -d @${REPO_TIMESTAMP} +%y.%m)-${REPO_COMMIT} >> $GITHUB_ENV

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

    - name: login into registry
      run: |
        BASE64_AUTH=`echo -n "$REGISTRY_USER:$REGISTRY_PASSWORD" | base64`
        mkdir -p ~/.docker
        echo "{\"auths\": {\"registry-rw.fakecake.org\": {\"auth\": \"$BASE64_AUTH\"}}}" > ~/.docker/config.json
      env:
          REGISTRY_USER: ${{ secrets.REGISTRY_USER }}
          REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
      if: ${{ !!secrets.REGISTRY_PUSH_ENABLED }}

    - name: build web-nginx image
      uses: https://github.com/docker/build-push-action@v4
      with:
        push: ${{ !!secrets.REGISTRY_PUSH_ENABLED }}
        context: .docker/web-nginx
        tags: |
          registry-rw.fakecake.org/cthulhoo/the-epube-web-nginx:latest
          registry-rw.fakecake.org/cthulhoo/the-epube-web-nginx:${{ env.BUILD_TAG }}
        provenance: false

    - name: build dict image
      uses: https://github.com/docker/build-push-action@v4
      with:
        push: ${{ !!secrets.REGISTRY_PUSH_ENABLED }}
        context: .docker/dict
        tags: |
          registry-rw.fakecake.org/cthulhoo/the-epube-dict:latest
          registry-rw.fakecake.org/cthulhoo/the-epube-dict:${{ env.BUILD_TAG }}
        provenance: false

    - name: build app image
      uses: https://github.com/docker/build-push-action@v4
      with:
        push: ${{ !!secrets.REGISTRY_PUSH_ENABLED }}
        context: .docker/app
        build-contexts:
          app-src=.
        tags: |
          registry-rw.fakecake.org/cthulhoo/the-epube-fpm-static:latest
          registry-rw.fakecake.org/cthulhoo/the-epube-fpm-static:${{ env.BUILD_TAG }}
        provenance: false

    - name: login into docker hub
      run: |
        BASE64_AUTH=`echo -n "$REGISTRY_USER:$REGISTRY_PASSWORD" | base64`
        mkdir -p ~/.docker
        echo "{\"auths\": {\"$REGISTRY_HOST\": {\"auth\": \"$BASE64_AUTH\"}}}" > ~/.docker/config.json
      env:
          REGISTRY_USER: ${{ secrets.REGISTRY_GITHUB_USER }}
          REGISTRY_PASSWORD: ${{ secrets.REGISTRY_GITHUB_ACCESS_TOKEN }}
          REGISTRY_HOST: https://index.docker.io/v1/
      if: ${{ !!secrets.REGISTRY_GITHUB_PUSH_ENABLED }}

    - name: build web-nginx image
      uses: https://github.com/docker/build-push-action@v4
      with:
        push: ${{ !!secrets.REGISTRY_GITHUB_PUSH_ENABLED }}
        context: .docker/web-nginx
        tags: |
          cthulhoo/the-epube-web-nginx:latest
          cthulhoo/the-epube-web-nginx:${{ env.BUILD_TAG }}
        provenance: false

    - name: build dict image
      uses: https://github.com/docker/build-push-action@v4
      with:
        push: ${{ !!secrets.REGISTRY_GITHUB_PUSH_ENABLED }}
        context: .docker/dict
        tags: |
          cthulhoo/the-epube-dict:latest
          cthulhoo/the-epube-dict:${{ env.BUILD_TAG }}
        provenance: false

    - name: build app image
      uses: https://github.com/docker/build-push-action@v4
      with:
        push: ${{ !!secrets.REGISTRY_GITHUB_PUSH_ENABLED }}
        context: .docker/app
        build-contexts:
          app-src=.
        tags: |
          cthulhoo/the-epube-fpm-static:latest
          cthulhoo/the-epube-fpm-static:${{ env.BUILD_TAG }}
        provenance: false