AzuraCast/.github/workflows/default.yml

223 lines
6.3 KiB
YAML
Raw Normal View History

2021-10-24 00:19:37 +02:00
name: Build, Test and Publish
on:
pull_request:
branches:
2021-02-11 03:52:15 +01:00
- main
2021-10-24 00:19:37 +02:00
push:
paths-ignore:
- '*.md'
- '.github/*.yml'
- '.github/ISSUE_TEMPLATE/*.md'
- 'install.sh' # Ansible-only scripts and folders
- 'update.sh'
- 'util/ansible/**'
2021-10-24 00:19:37 +02:00
branches:
- ci-testing
2021-02-11 03:52:15 +01:00
- main
2020-05-21 09:17:16 +02:00
- stable
2021-10-24 00:19:37 +02:00
tags:
- '*'
2021-10-24 00:19:37 +02:00
schedule:
- cron: '0 2 * * 0' # Weekly on Sundays at 02:00
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
2021-10-24 00:19:37 +02:00
jobs:
build:
2021-12-13 16:03:14 +01:00
name: Build and Test
2021-10-24 00:19:37 +02:00
runs-on: ubuntu-latest
env:
APPLICATION_ENV: testing
NODE_ENV: production
steps:
- uses: actions/checkout@master
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
2021-10-24 00:19:37 +02:00
extensions: intl, maxminddb
tools: composer:v2, cs2pr
2021-12-13 14:54:14 +01:00
- name: Cache PHP dependencies
uses: actions/cache@v2
with:
path: vendor
key: ${{ runner.OS }}-build-${{ hashFiles('composer.lock') }}
2021-12-13 14:54:14 +01:00
2021-10-24 00:19:37 +02:00
- name: Set console permissions and clear static assets.
run: |
rm -rf web/static/dist
rm -rf web/static/webpack_dist
2021-03-26 23:44:13 +01:00
rm -rf web/static/webpack.json
rm -rf web/static/assets.json
chmod a+x bin/console
2021-10-24 00:19:37 +02:00
- name: Run Composer install
run: |
composer install --no-interaction --ignore-platform-reqs
2021-10-24 00:19:37 +02:00
- name: Run PHP Linter
run: |
vendor/bin/parallel-lint . --exclude vendor --checkstyle | cs2pr
2021-10-24 00:19:37 +02:00
- name: Run PHPStan
run: |
vendor/bin/phpstan analyze --error-format=checkstyle | cs2pr
2021-10-24 00:19:37 +02:00
- name: Run PHP Code Sniffer
run: |
vendor/bin/phpcs --report=checkstyle | cs2pr
2021-10-24 00:19:37 +02:00
- name: Clear existing locales.
if: github.event_name == 'push' || github.event_name == 'schedule'
run: |
rm -rf translations/*.UTF-8
2021-10-24 00:19:37 +02:00
- name: Generate new translations from existing code.
if: github.event_name == 'push' || github.event_name == 'schedule'
run: |
cd frontend
npm ci
npm run generate-locales
cd ..
bin/console locale:generate
2021-10-24 00:19:37 +02:00
- name: Pull latest translations.
if: github.event_name == 'push' || github.event_name == 'schedule'
2022-04-27 20:12:46 +02:00
uses: crowdin/github-action@1.4.8
2021-10-24 00:19:37 +02:00
with:
upload_sources: true
download_translations: true
export_only_approved: false
push_translations: false
crowdin_branch_name: main
config: crowdin.yaml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }}
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
- name: Import locales, build static assets.
run: |
bin/console locale:import
cd frontend
npm run import-locales
npm run build
2021-10-24 00:19:37 +02:00
- name: Build OpenAPI Docs
run: bin/console azuracast:api:docs
2021-11-18 17:37:45 +01:00
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
2021-11-18 17:37:45 +01:00
- name: Build Web Image
2021-12-13 16:03:14 +01:00
uses: docker/build-push-action@v2
2021-11-18 17:37:45 +01:00
with:
context: .
load: true
tags: ghcr.io/azuracast/azuracast:latest
cache-from: type=registry,ref=ghcr.io/azuracast/azuracast:buildcache
2021-11-18 17:37:45 +01:00
2021-10-24 00:19:37 +02:00
- name: Set up functional test environment.
run: |
cp sample.env .env
cp azuracast.sample.env azuracast.env
cp docker-compose.sample.yml docker-compose.yml
cp docker-compose.testing.yml docker-compose.override.yml
2021-10-24 00:19:37 +02:00
- name: Run functional test suite.
run: |
chmod 777 tests/_output/
chmod 777 tests/_support/_generated
docker-compose run --rm web azuracast_ci
2021-10-24 00:19:37 +02:00
- name: Stop all running containers.
run: |
docker-compose down
2021-10-24 00:19:37 +02:00
- name: Echo test output directory
if: failure()
run: |
docker-compose logs
cat tests/_output/*
2021-12-13 16:03:14 +01:00
- name: Upload built static assets and translations
uses: actions/upload-artifact@v2
with:
name: assets
if-no-files-found: error
path: |
translations
2021-12-13 16:03:14 +01:00
web/static/dist
web/static/webpack_dist
2021-12-13 16:03:14 +01:00
web/static/webpack.json
web/static/assets.json
web/static/api/openapi.yml
2021-12-13 16:03:14 +01:00
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
- name: Download built static assets from previous step
uses: actions/download-artifact@v2
with:
name: assets
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
id: qemu
with:
platforms: arm64
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
2021-10-24 00:19:37 +02:00
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build Docker Metadata
id: meta
2022-02-12 09:11:34 +01:00
uses: docker/metadata-action@v3
2021-10-24 00:19:37 +02:00
with:
images: |
azuracast/azuracast
ghcr.io/azuracast/azuracast
2021-10-24 00:19:37 +02:00
tags: |
type=raw,value=latest,enable=${{ endsWith(github.ref, github.event.repository.default_branch) }}
type=ref,event=branch
type=semver,pattern={{version}}
2021-02-12 02:46:36 +01:00
2021-12-13 16:03:14 +01:00
- name: Publish to Docker Hub
uses: docker/build-push-action@v2
2021-10-24 00:19:37 +02:00
with:
context: .
push: true
2021-12-13 15:25:09 +01:00
platforms: linux/amd64,linux/arm64
2021-10-24 00:19:37 +02:00
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=ghcr.io/azuracast/azuracast:buildcache
cache-to: type=registry,ref=ghcr.io/azuracast/azuracast:buildcache,mode=max