|
| 1 | +name: Publish |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'v*' |
| 7 | + |
| 8 | +jobs: |
| 9 | + code_coverage: |
| 10 | + name: Code coverage |
| 11 | + runs-on: ubuntu-latest |
| 12 | + services: |
| 13 | + mysql: |
| 14 | + image: mysql/mysql-server:8.0 |
| 15 | + ports: |
| 16 | + - 3306:3306 |
| 17 | + env: |
| 18 | + MYSQL_ROOT_PASSWORD: 'root' |
| 19 | + MYSQL_ROOT_HOST: '%' |
| 20 | + MYSQL_DATABASE: 'testing' |
| 21 | + MYSQL_USER: 'testing' |
| 22 | + MYSQL_PASSWORD: 'testing' |
| 23 | + options: >- |
| 24 | + --health-cmd="mysqladmin ping --silent" |
| 25 | + --health-interval=10s |
| 26 | + --health-timeout=5s |
| 27 | + --health-retries=3 |
| 28 | + steps: |
| 29 | + - name: Checkout code |
| 30 | + uses: actions/checkout@v4 |
| 31 | + |
| 32 | + - name: Setup environment |
| 33 | + uses: ./.github/actions/setup-env |
| 34 | + |
| 35 | + - name: Run tests |
| 36 | + run: vendor/bin/phpunit --coverage-clover clover.xml |
| 37 | + env: |
| 38 | + APP_KEY: ${{ secrets.TESTING_APP_KEY }} |
| 39 | + |
| 40 | + - name: Upload coverage to Codecov |
| 41 | + uses: codecov/codecov-action@v4 |
| 42 | + with: |
| 43 | + files: clover.xml |
| 44 | + flags: release |
| 45 | + verbose: true |
| 46 | + env: |
| 47 | + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} |
| 48 | + |
| 49 | + publish: |
| 50 | + runs-on: ubuntu-latest |
| 51 | + permissions: |
| 52 | + contents: write |
| 53 | + packages: write |
| 54 | + pages: write |
| 55 | + steps: |
| 56 | + - name: Checkout repository |
| 57 | + uses: actions/checkout@v4 |
| 58 | + with: |
| 59 | + persist-credentials: false |
| 60 | + fetch-depth: 0 |
| 61 | + |
| 62 | + - name: Setup environment |
| 63 | + uses: ./.github/actions/setup-env |
| 64 | + |
| 65 | + - name: Generate API documentation |
| 66 | + run: php artisan l5-swagger:generate |
| 67 | + |
| 68 | + - name: Set API documentation version |
| 69 | + run: sed -i "s/0.0.0/$TAG/g" storage/api-docs/api-docs.json |
| 70 | + env: |
| 71 | + TAG: ${{ github.ref_name }} |
| 72 | + |
| 73 | + - name: Copy API documentation |
| 74 | + run: | |
| 75 | + mkdir -p docs |
| 76 | + cp storage/api-docs/api-docs.json docs/api-docs-${{ github.ref_name }}.json |
| 77 | + cp storage/api-docs/api-docs.json docs/api-docs-latest.json |
| 78 | + cp DEPENDENCIES.md docs/DEPENDENCIES-${{ github.ref_name }}.md |
| 79 | + cp DEPENDENCIES.md docs/DEPENDENCIES-latest.md |
| 80 | + cp CHANGELOG.md docs/CHANGELOG.md |
| 81 | +
|
| 82 | + - name: Deploy to GitHub Pages |
| 83 | + uses: peaceiris/actions-gh-pages@v3 |
| 84 | + with: |
| 85 | + personal_token: ${{ secrets.GITHUB_TOKEN }} |
| 86 | + publish_dir: ./docs |
| 87 | + cname: documents.obms.one |
| 88 | + keep_files: true |
| 89 | + publish_branch: gh-pages |
| 90 | + |
| 91 | + - name: Log in to GitHub Container Registry |
| 92 | + run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin |
| 93 | + |
| 94 | + - name: Build and push app image |
| 95 | + run: | |
| 96 | + docker build -t ghcr.io/forepath/obms-app:${{ github.ref_name }} -f docker/production/Dockerfile.fpm . |
| 97 | + docker push ghcr.io/forepath/obms-app:${{ github.ref_name }} |
| 98 | + docker tag ghcr.io/forepath/obms-app:${{ github.ref_name }} ghcr.io/forepath/obms-app:latest |
| 99 | + docker push ghcr.io/forepath/obms-app:latest |
| 100 | +
|
| 101 | + - name: Build and push worker image |
| 102 | + run: | |
| 103 | + docker build -t ghcr.io/forepath/obms-worker:${{ github.ref_name }} -f docker/production/Dockerfile.worker . |
| 104 | + docker push ghcr.io/forepath/obms-worker:${{ github.ref_name }} |
| 105 | + docker tag ghcr.io/forepath/obms-worker:${{ github.ref_name }} ghcr.io/forepath/obms-worker:latest |
| 106 | + docker push ghcr.io/forepath/obms-worker:latest |
| 107 | +
|
| 108 | + notify: |
| 109 | + runs-on: ubuntu-latest |
| 110 | + needs: publish |
| 111 | + steps: |
| 112 | + - name: Trigger remote update |
| 113 | + uses: peter-evans/repository-dispatch@v1 |
| 114 | + with: |
| 115 | + repository: forepath/obms-documentation |
| 116 | + event-type: core-release |
| 117 | + token: ${{ secrets.DOCUMENTATION_REPOSITORY_TOKEN }} |
0 commit comments