Add CI step to push to Redocly.

This commit is contained in:
Buster "Silver Eagle" Neece 2021-10-23 17:19:37 -05:00
parent 3bc7afde04
commit f815fb0119
No known key found for this signature in database
GPG Key ID: 6D9E12FF03411F4E
1 changed files with 141 additions and 117 deletions

View File

@ -1,104 +1,104 @@
name : Build, Test and Publish name: Build, Test and Publish
on : on:
pull_request : pull_request:
branches : branches:
- main - main
push : push:
paths-ignore : paths-ignore:
- '.github/*.yml' - '.github/*.yml'
- '.github/ISSUE_TEMPLATE/*.md' - '.github/ISSUE_TEMPLATE/*.md'
- 'install.sh' # Ansible-only scripts and folders - 'install.sh' # Ansible-only scripts and folders
- 'update.sh' - 'update.sh'
- 'util/ansible/**' - 'util/ansible/**'
branches : branches:
- ci-testing - ci-testing
- main - main
- stable - stable
tags : tags:
- '*' - '*'
schedule : schedule:
- cron : '0 2 * * 0' # Weekly on Sundays at 02:00 - cron: '0 2 * * 0' # Weekly on Sundays at 02:00
jobs : jobs:
build : build:
name : Build and Test name: Build and Test
runs-on : ubuntu-latest runs-on: ubuntu-latest
env : env:
APPLICATION_ENV : testing APPLICATION_ENV: testing
NODE_ENV : production NODE_ENV: production
steps : steps:
- uses : actions/checkout@master - uses: actions/checkout@master
- name : Setup PHP - name: Setup PHP
uses : shivammathur/setup-php@v2 uses: shivammathur/setup-php@v2
with : with:
php-version : '8.0' php-version: '8.0'
extensions : intl, maxminddb extensions: intl, maxminddb
tools : composer:v2, cs2pr tools: composer:v2, cs2pr
- name : Cache PHP dependencies - name: Cache PHP dependencies
uses : actions/cache@v2 uses: actions/cache@v2
with : with:
path : vendor path: vendor
key : ${{ runner.OS }}-build-${{ hashFiles('**/composer.lock') }} key: ${{ runner.OS }}-build-${{ hashFiles('**/composer.lock') }}
- name : Set console permissions and clear static assets. - name: Set console permissions and clear static assets.
run : | run: |
rm -rf web/static/dist rm -rf web/static/dist
rm -rf web/static/webpack_dist rm -rf web/static/webpack_dist
rm -rf web/static/webpack.json rm -rf web/static/webpack.json
rm -rf web/static/assets.json rm -rf web/static/assets.json
chmod a+x bin/console chmod a+x bin/console
- name : Run Composer install - name: Run Composer install
run : | run: |
composer install --no-interaction --ignore-platform-reqs composer install --no-interaction --ignore-platform-reqs
- name : Run PHP Linter - name: Run PHP Linter
run : | run: |
vendor/bin/parallel-lint . --exclude vendor --checkstyle | cs2pr vendor/bin/parallel-lint . --exclude vendor --checkstyle | cs2pr
- name : Run PHPStan - name: Run PHPStan
run : | run: |
vendor/bin/phpstan analyze --error-format=checkstyle | cs2pr vendor/bin/phpstan analyze --error-format=checkstyle | cs2pr
- name : Run PHP Code Sniffer - name: Run PHP Code Sniffer
run : | run: |
vendor/bin/phpcs --report=checkstyle | cs2pr vendor/bin/phpcs --report=checkstyle | cs2pr
- name : Clear existing locales. - name: Clear existing locales.
if : github.event_name == 'push' || github.event_name == 'schedule' if: github.event_name == 'push' || github.event_name == 'schedule'
run : | run: |
rm -rf resources/locale/compiled rm -rf resources/locale/compiled
rm -rf resources/locale/*.UTF-8 rm -rf resources/locale/*.UTF-8
rm -rf resources/locale/translations.json rm -rf resources/locale/translations.json
mkdir -p resources/locale/compiled mkdir -p resources/locale/compiled
- name : Generate new translations from existing code. - name: Generate new translations from existing code.
if : github.event_name == 'push' || github.event_name == 'schedule' if: github.event_name == 'push' || github.event_name == 'schedule'
run : | run: |
bin/console locale:generate bin/console locale:generate
cd frontend cd frontend
npm ci npm ci
npm run generate-locales npm run generate-locales
- name : Pull latest translations. - name: Pull latest translations.
if : github.event_name == 'push' || github.event_name == 'schedule' if: github.event_name == 'push' || github.event_name == 'schedule'
uses : crowdin/github-action@1.0.18 uses: crowdin/github-action@1.0.18
with : with:
upload_sources : true upload_sources: true
download_translations : true download_translations: true
export_only_approved : false export_only_approved: false
push_translations : false push_translations: false
crowdin_branch_name : main crowdin_branch_name: main
config : crowdin.yaml config: crowdin.yaml
env : env:
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CROWDIN_PROJECT_ID : ${{ secrets.CROWDIN_PROJECT_ID }} CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }}
CROWDIN_PERSONAL_TOKEN : ${{ secrets.CROWDIN_PERSONAL_TOKEN }} CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
- name : Import locales, build static assets. - name: Import locales, build static assets.
run : | run: |
bin/console locale:import bin/console locale:import
cd frontend cd frontend
@ -106,8 +106,11 @@ jobs :
npm run import-locales npm run import-locales
npm run build npm run build
- name : Set up functional test environment. - name: Build OpenAPI Docs
run : | run: bin/console azuracast:api:docs
- name: Set up functional test environment.
run: |
cp sample.env .env cp sample.env .env
cp azuracast.sample.env azuracast.env cp azuracast.sample.env azuracast.env
cp docker-compose.sample.yml docker-compose.yml cp docker-compose.sample.yml docker-compose.yml
@ -118,89 +121,110 @@ jobs :
docker-compose run --rm --user="azuracast" web azuracast_install docker-compose run --rm --user="azuracast" web azuracast_install
- name : Run functional test suite. - name: Run functional test suite.
run : | run: |
chmod 777 tests/_output/ chmod 777 tests/_output/
chmod 777 tests/_support/_generated chmod 777 tests/_support/_generated
docker-compose run --rm --user="azuracast" web composer codeception-no-coverage docker-compose run --rm --user="azuracast" web composer codeception-no-coverage
- name : Stop all running containers. - name: Stop all running containers.
run : | run: |
docker-compose down docker-compose down
- name : Echo test output directory - name: Echo test output directory
if : failure() if: failure()
run : | run: |
docker-compose logs docker-compose logs
cat tests/_output/* cat tests/_output/*
- name : Upload built static assets and translations - name: Upload built static assets and translations
uses : actions/upload-artifact@v2 uses: actions/upload-artifact@v2
with : with:
name : assets name: assets
if-no-files-found : error if-no-files-found: error
path : | path: |
resources/locale/compiled resources/locale/compiled
resources/locale/translations.json resources/locale/translations.json
web/static/dist web/static/dist
web/static/webpack_dist web/static/webpack_dist
web/static/webpack.json web/static/webpack.json
web/static/assets.json web/static/assets.json
web/static/api/openapi.yml
publish : push-api-docs:
name : Publish name: Push API Docs
needs : build needs: build
runs-on : ubuntu-latest runs-on: ubuntu-latest
if : github.event_name == 'push' || github.event_name == 'schedule' if: |
steps : github.event_name == 'push' || github.event_name == 'schedule'
- uses : actions/checkout@master endsWith(github.ref, github.event.repository.default_branch)
env:
REDOCLY_AUTHORIZATION: ${{ secrets.REDOCLY_AUTHORIZATION }}
steps:
- uses: actions/checkout@master
- name : Reduce Git repository size. - name: Download built static assets from previous step
run : | uses: actions/download-artifact@v2
with:
name: assets
- name: Submit OpenAPI YML to Redocly
run: npx @redocly/openapi-cli@latest push ./web/static/api/openapi.yml "@azuracast/AzuraCast@Latest"
publish:
name: Publish
needs: build
runs-on: ubuntu-latest
if: github.event_name == 'push' || github.event_name == 'schedule'
steps:
- uses: actions/checkout@master
- name: Reduce Git repository size.
run: |
git gc --prune=now --aggressive git gc --prune=now --aggressive
- name : Download built static assets from previous step - name: Download built static assets from previous step
uses : actions/download-artifact@v2 uses: actions/download-artifact@v2
with : with:
name : assets name: assets
# - name : Set up QEMU # - name : Set up QEMU
# uses : docker/setup-qemu-action@v1 # uses : docker/setup-qemu-action@v1
- name : Set up Docker Buildx - name: Set up Docker Buildx
uses : docker/setup-buildx-action@v1 uses: docker/setup-buildx-action@v1
- name : Login to DockerHub - name: Login to DockerHub
uses : docker/login-action@v1 uses: docker/login-action@v1
with : with:
username : ${{ secrets.DOCKERHUB_USERNAME }} username: ${{ secrets.DOCKERHUB_USERNAME }}
password : ${{ secrets.DOCKERHUB_TOKEN }} password: ${{ secrets.DOCKERHUB_TOKEN }}
- name : Login to GitHub Container Registry - name: Login to GitHub Container Registry
uses : docker/login-action@v1 uses: docker/login-action@v1
with : with:
registry : ghcr.io registry: ghcr.io
username : ${{ github.repository_owner }} username: ${{ github.repository_owner }}
password : ${{ secrets.GITHUB_TOKEN }} password: ${{ secrets.GITHUB_TOKEN }}
- name : Build Docker Metadata - name: Build Docker Metadata
id : meta id: meta
uses : crazy-max/ghaction-docker-meta@v2 uses: crazy-max/ghaction-docker-meta@v2
with : with:
images : | images: |
azuracast/azuracast_web_v2 azuracast/azuracast_web_v2
ghcr.io/azuracast/web ghcr.io/azuracast/web
tags : | tags: |
type=raw,value=latest,enable=${{ endsWith(github.ref, github.event.repository.default_branch) }} type=raw,value=latest,enable=${{ endsWith(github.ref, github.event.repository.default_branch) }}
type=ref,event=branch type=ref,event=branch
type=semver,pattern={{version}} type=semver,pattern={{version}}
- name : Publish to Docker Hub - name: Publish to Docker Hub
uses : docker/build-push-action@v2 uses: docker/build-push-action@v2
with : with:
context : . context: .
# platforms : linux/amd64,linux/arm64 # platforms : linux/amd64,linux/arm64
cache-from : type=registry,ref=azuracast/azuracast_web_v2:latest cache-from: type=registry,ref=azuracast/azuracast_web_v2:latest
push : true push: true
tags : ${{ steps.meta.outputs.tags }} tags: ${{ steps.meta.outputs.tags }}
labels : ${{ steps.meta.outputs.labels }} labels: ${{ steps.meta.outputs.labels }}