[StepSecurity] ci: Harden GitHub Actions #135
This file contains hidden or 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
| # https://help.github.com/en/categories/automating-your-workflow-with-github-actions | |
| name: "Deploy API Reference" | |
| on: | |
| push: | |
| branches: | |
| - "2.3.x" | |
| concurrency: | |
| group: "pages" | |
| cancel-in-progress: false | |
| jobs: | |
| build: | |
| name: "Build API References Pages" | |
| runs-on: "ubuntu-latest" | |
| strategy: | |
| matrix: | |
| branch: | |
| - "1.23.x" | |
| - "2.0.x" | |
| - "2.1.x" | |
| - "2.2.x" | |
| - "2.3.x" | |
| steps: | |
| - name: Harden the runner (Audit all outbound calls) | |
| uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2 | |
| with: | |
| egress-policy: audit | |
| - name: "Checkout" | |
| uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1 | |
| with: | |
| ref: ${{ matrix.branch }} | |
| - name: "Install PHP" | |
| uses: "shivammathur/setup-php@44454db4f0199b8b9685a5d763dc37cbf79108e1" # v2 | |
| with: | |
| coverage: "none" | |
| php-version: "8.1" | |
| extensions: mbstring | |
| tools: composer:v2 | |
| - name: "Install dependencies" | |
| run: "composer update --no-interaction --no-progress" | |
| - name: "Install ApiGen dependencies" | |
| working-directory: "apigen" | |
| run: "composer install --no-interaction --no-progress" | |
| - name: "Run ApiGen" | |
| run: "apigen/vendor/bin/apigen -c apigen/apigen.neon --output docs/${{ matrix.branch }} -- src" | |
| - name: "Copy favicon" | |
| run: "cp apigen/favicon.png docs/favicon.png" | |
| - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 | |
| with: | |
| name: docs-${{ matrix.branch }} | |
| path: docs/* | |
| merge: | |
| name: "Merge docs" | |
| needs: build | |
| runs-on: "ubuntu-latest" | |
| steps: | |
| - name: Harden the runner (Audit all outbound calls) | |
| uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2 | |
| with: | |
| egress-policy: audit | |
| - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 | |
| with: | |
| pattern: docs-* | |
| path: docs | |
| merge-multiple: true | |
| - name: Upload artifact | |
| uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa # v3.0.1 | |
| with: | |
| path: 'docs' | |
| deploy: | |
| needs: merge | |
| # from https://github.com/actions/deploy-pages | |
| permissions: | |
| pages: write | |
| id-token: write | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Harden the runner (Audit all outbound calls) | |
| uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2 | |
| with: | |
| egress-policy: audit | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4.0.5 |