mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-04-07 21:44:51 +00:00
Refactor CI, Build docker on push
This commit is contained in:
105
.github/workflows/ci.yaml
vendored
105
.github/workflows/ci.yaml
vendored
@@ -1,37 +1,86 @@
|
||||
name: CI
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
tags:
|
||||
- "*"
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
env:
|
||||
INVOICESHELF_VERSION: 1.0.0
|
||||
jobs:
|
||||
build-test:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
php: ['7.4', '8.0']
|
||||
build-test:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
php: ['8.1', '8.2']
|
||||
|
||||
name: PHP ${{ matrix.php }}
|
||||
name: PHP ${{ matrix.php }}
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Install dependencies
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: ${{ matrix.php }}
|
||||
extensions: exif
|
||||
- name: Install dependencies
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: ${{ matrix.php }}
|
||||
extensions: exif
|
||||
|
||||
- name: Install PHP 7 dependencies
|
||||
run: composer update --no-interaction --no-progress
|
||||
if: "matrix.php < 8"
|
||||
- name: Install PHP dependencies
|
||||
run: composer update --ignore-platform-req=php --no-interaction --no-progress
|
||||
|
||||
- name: Install PHP 8 dependencies
|
||||
run: composer update --ignore-platform-req=php --no-interaction --no-progress
|
||||
if: "matrix.php >= 8"
|
||||
- name: Check coding style
|
||||
run: ./vendor/bin/php-cs-fixer fix -v --dry-run --using-cache=no --config=.php-cs-fixer.dist.php
|
||||
|
||||
- name: Check coding style
|
||||
run: ./vendor/bin/php-cs-fixer fix -v --dry-run --using-cache=no --config=.php-cs-fixer.dist.php
|
||||
|
||||
- name: Unit Tests
|
||||
run: php ./vendor/bin/pest
|
||||
- name: Unit Tests
|
||||
run: php ./vendor/bin/pest
|
||||
docker:
|
||||
if: ${{ needs.build-test.result == 'success' && github.event_name != 'pull_request'}}
|
||||
name: Docker build and publish
|
||||
runs-on: ubuntu-latest
|
||||
needs:
|
||||
- build-test
|
||||
steps:
|
||||
- name: derive version tag
|
||||
run: |
|
||||
if [[ "${{ github.ref }}" =~ ^refs/tags* ]]; then
|
||||
GITHUB_TAG=${GITHUB_REF#refs/tags/}
|
||||
echo "running for a release $GITHUB_TAG"
|
||||
if [ "$GITHUB_TAG" != "${{ env.INVOICESHELF_VERSION }}" ]; then
|
||||
echo "tag $GITHUB_TAG pushed does not match with INVOICESHELF_VERSION ${{ env.INVOICESHELF_VERSION }} in .github/worlflows/ci. Please push correct release tag"
|
||||
exit 1
|
||||
fi
|
||||
echo "VERSION_TAG=${{ env.INVOICESHELF_VERSION }}" >> $GITHUB_ENV
|
||||
else
|
||||
echo "running for a master commit"
|
||||
if [ $(git tag -l ${{ env.INVOICESHELF_VERSION }}) ]; then
|
||||
echo "Version ${{ env.INVOICESHELF_VERSION }} already released. Please update your version in .github/worlflows/ci"
|
||||
exit 1
|
||||
fi
|
||||
echo "VERSION_TAG=${{ env.INVOICESHELF_VERSION }}-${{ github.run_number }}" >> $GITHUB_ENV
|
||||
fi
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
- name: Login to DockerHub
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_HUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_HUB_TOKEN }}
|
||||
- name: Docker Build and push invoiceshelf-php
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
context: .
|
||||
file: docker/Dockerfile
|
||||
push: true
|
||||
tags: invoiceshelf/invoiceshelf-php:${{env.VERSION_TAG}},invoiceshelf/invoiceshelf-php:latest
|
||||
- name: Docker Build and push invoiceshelf-nginx
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
context: .
|
||||
file: docker/nginx.Dockerfile
|
||||
push: true
|
||||
tags: invoiceshelf/invoiceshelf-nginx:${{env.VERSION_TAG}},invoiceshelf/invoiceshelf-nginx:latest
|
||||
|
||||
Reference in New Issue
Block a user