|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ "main" ] |
| 6 | + pull_request: |
| 7 | + branches: [ "main" ] |
| 8 | + schedule: |
| 9 | + - cron: '40 0 * * *' |
| 10 | + |
| 11 | +env: |
| 12 | + COMPOSER_HOME: /.composer |
| 13 | + SECRET_DETECTION_JSON_REPORT_FILE: "gitleaks.json" |
| 14 | + |
| 15 | +jobs: |
| 16 | + build_image: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + strategy: |
| 19 | + matrix: |
| 20 | + php-version: |
| 21 | + - 7.3-alpine |
| 22 | + - 7.4-alpine |
| 23 | + - 8.0-alpine |
| 24 | + - 8.1-alpine |
| 25 | + steps: |
| 26 | + - name: Login to Docker Hub |
| 27 | + uses: docker/login-action@v3 |
| 28 | + with: |
| 29 | + username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 30 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 31 | + - name: Build Docker image |
| 32 | + uses: docker/build-push-action@v6 |
| 33 | + with: |
| 34 | + context: . |
| 35 | + file: ./Dockerfile |
| 36 | + push: true |
| 37 | + tags: deepl-php-${{ matrix.php-version }}:latest |
| 38 | + |
| 39 | + code_sniffer: |
| 40 | + strategy: |
| 41 | + matrix: |
| 42 | + php-version: |
| 43 | + - '7.3-alpine' |
| 44 | + - '7.4-alpine' |
| 45 | + - '8.0-alpine' |
| 46 | + - '8.1-alpine' |
| 47 | + runs-on: deepl-php-${{ matrix.php-version }} |
| 48 | + steps: |
| 49 | + - name: Checkout |
| 50 | + uses: actions/checkout@v4 |
| 51 | + - name: Code sniffer check |
| 52 | + run: vendor/bin/phpcs |
| 53 | + |
| 54 | + license_check: |
| 55 | + runs-on: ubuntu-latest |
| 56 | + steps: |
| 57 | + - name: Checkout |
| 58 | + uses: actions/checkout@v4 |
| 59 | + - name: License check |
| 60 | + run: | |
| 61 | + ./license_checker.sh '*.php' | tee license_check_output.txt |
| 62 | + [ ! -s license_check_output.txt ] |
| 63 | +
|
| 64 | + secret_detection: |
| 65 | + runs-on: ubuntu-latest |
| 66 | + steps: |
| 67 | + - name: Checkout |
| 68 | + uses: actions/checkout@v4 |
| 69 | + with: |
| 70 | + fetch-depth: 0 |
| 71 | + - name: Install and run secret detection |
| 72 | + run: | |
| 73 | + wget https://github.com/gitleaks/gitleaks/releases/download/v8.18.4/gitleaks_8.18.4_linux_x64.tar.gz |
| 74 | + tar -xzf gitleaks_8.18.4_linux_x64.tar.gz |
| 75 | + EXITCODE=0 |
| 76 | + ./gitleaks detect -r ${SECRET_DETECTION_JSON_REPORT_FILE} --source . --log-opts="--all --full-history" || EXITCODE=$? |
| 77 | + if [[ $EXITCODE -ne 0 ]]; then |
| 78 | + exit $EXITCODE |
| 79 | + fi |
| 80 | + - name: Upload secret detection artifact |
| 81 | + uses: actions/upload-artifact@v4 |
| 82 | + with: |
| 83 | + name: secret-detection-results |
| 84 | + path: gitleaks.json |
| 85 | + |
| 86 | +# Test stage is disabled for now. Code needs to be tested |
| 87 | + |
| 88 | +####################################################### |
| 89 | +# test: |
| 90 | +# strategy: |
| 91 | +# matrix: |
| 92 | +# php-version: |
| 93 | +# - '7.3-alpine' |
| 94 | +# - '7.4-alpine' |
| 95 | +# - '8.0-alpine' |
| 96 | +# - '8.1-alpine' |
| 97 | +# use-mock-server: |
| 98 | +# - '' |
| 99 | +# - 'use mock server' |
| 100 | +# runs-on: deepl-php-${{ matrix.php-version }} |
| 101 | +# env: |
| 102 | +# DEEPL_SERVER_URL: http://deepl-mock:3000 |
| 103 | +# DEEPL_MOCK_SERVER_PORT: 3000 |
| 104 | +# DEEPL_PROXY_URL: http://deepl-mock:3001 |
| 105 | +# DEEPL_MOCK_PROXY_SERVER_PORT: 3001 |
| 106 | +# steps: |
| 107 | +# - name: Checkout |
| 108 | +# uses: actions/checkout@v4 |
| 109 | +# - name: Test |
| 110 | +# run: | |
| 111 | +# if [[ ! -z "${{ matrix.use-mock-server }}" ]]; then |
| 112 | +# echo "Using mock server" |
| 113 | +# export DEEPL_SERVER_URL=http://deepl-mock:3000 |
| 114 | +# export DEEPL_MOCK_SERVER_PORT=3000 |
| 115 | +# export DEEPL_PROXY_URL=http://deepl-mock:3001 |
| 116 | +# export DEEPL_MOCK_PROXY_SERVER_PORT=3001 |
| 117 | +# fi |
| 118 | +# vendor/bin/phpunit |
| 119 | +# - name: Upload test results |
| 120 | +# uses: actions/upload-artifact@v4 |
| 121 | +# with: |
| 122 | +# name: test-results |
| 123 | +# path: | |
| 124 | +# reports/cobertura.xml |
| 125 | +# reports/junit.xml |
0 commit comments