Skip to content

style: fix cs issues #95

style: fix cs issues

style: fix cs issues #95

name: Test, build and deploy
on: push
env:
IMAGE: ghcr.io/${{ github.repository }}:${{ github.sha }}
jobs:
test:
name: Run unit tests and static analysis
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
tools: php-cs-fixer
- name: Output some debug information about the PHP version
run: |
composer --version
php -v
php -i
php -m
- name: Validate composer files
run: composer validate --strict
- name: Get Composer Cache Directory
id: get-composer-cache-dir
run: echo "dir=$(composer config cache-files-dir)" >> ${GITHUB_OUTPUT}
- uses: actions/cache@v3
id: composer-cache
with:
path: ${{ steps.get-composer-cache-dir.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Install dependencies
run: composer install
- name: Run unit tests
run: vendor/bin/phpunit
- name: Run static analysis
run: vendor/bin/psalm --no-cache --show-info=true
- name: Check coding standard
run: php-cs-fixer fix --dry-run --diff
build:
name: Build docker container
runs-on: ubuntu-22.04
needs: test
steps:
- uses: actions/checkout@v3
- name: Build and publish Docker image
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
docker build --tag ${IMAGE} .
docker login ghcr.io -u ${GITHUB_REPOSITORY} -p ${GITHUB_TOKEN}
docker push ${IMAGE}
deploy-dev-gcp:
name: Deploy to dev-gcp
needs:
- test
- build
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: nais/deploy/actions/deploy@v1
env:
APIKEY: ${{ secrets.NAIS_DEPLOY_KEY }}
CLUSTER: dev-gcp
RESOURCE: .nais/nais.yml
VARS: .nais/dev-gcp-vars.json
deploy-prod-gcp:
if: ${{ github.ref == 'refs/heads/main' }}
name: Deploy to prod-gcp
needs:
- test
- build
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: nais/deploy/actions/deploy@v1
env:
APIKEY: ${{ secrets.NAIS_DEPLOY_KEY }}
CLUSTER: prod-gcp
RESOURCE: .nais/nais.yml
VARS: .nais/prod-gcp-vars.json