diff options
author | Andrew Dolgov <[email protected]> | 2023-03-25 22:41:47 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2023-03-25 22:41:47 +0300 |
commit | 723323d7462954a262368d621811a045710cd1ed (patch) | |
tree | d1c4031e09d11d8af9e39def52ad743c35084a45 /.gitea/workflows/build.yml | |
parent | d305532bcef91061c39db13872d44c4f859054b7 (diff) |
add gitea-CI docker builder
Diffstat (limited to '.gitea/workflows/build.yml')
-rw-r--r-- | .gitea/workflows/build.yml | 124 |
1 files changed, 124 insertions, 0 deletions
diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml new file mode 100644 index 000000000..da72774a8 --- /dev/null +++ b/.gitea/workflows/build.yml @@ -0,0 +1,124 @@ +# 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: npm install + run: npm install + + - name: eslint + run: npx eslint js plugins + + - 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 + + - uses: https://github.com/actions/cache/restore@v3 + id: cache-phpstan + with: + path: /tmp/phpstan + key: ${{ runner.os }}-phpstan-${{ steps.cache-hash.outputs.hash }} + + - name: phpstan + run: php81 -d memory_limit=-1 ./vendor/bin/phpstan --memory-limit=2G + + - uses: https://github.com/actions/cache/save@v3 + with: + path: /tmp/phpstan + key: ${{ steps.cache-phpstan.outputs.cache-primary-key }} + + - 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/ttrss-web-nginx:latest + registry-rw.fakecake.org/cthulhoo/ttrss-web-nginx:${{ 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/ttrss-fpm-pgsql-static:latest + registry-rw.fakecake.org/cthulhoo/ttrss-fpm-pgsql-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/ttrss-web-nginx:latest + cthulhoo/ttrss-web-nginx:${{ 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/ttrss-fpm-pgsql-static:latest + cthulhoo/ttrss-fpm-pgsql-static:${{ env.BUILD_TAG }} + provenance: false |