Merge pull request #32 from havstein/patch-1 #76
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: | | |
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 --prefer-dist | |
- name: Run unit tests | |
run: vendor/bin/phpunit | |
- name: Run static analysis | |
run: vendor/bin/psalm | |
- name: Check coding standard | |
run: php-cs-fixer fix --dry-run --diff | |
build: | |
name: Build docker container | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Build image | |
run: docker build --tag ${IMAGE} . | |
- name: Publish image | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
echo ${GITHUB_TOKEN} | docker login ghcr.io --username ${GITHUB_REPOSITORY} --password-stdin | |
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.yml | |
VARS: dev-gcp-vars.yml | |
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.yml | |
VARS: prod-gcp-vars.yml |