Merge pull request #3 from PHPCSStandards/dependabot/github_actions/s… #28
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
| name: Deploy static content to GH Pages | |
| on: | |
| # Runs on pushes targeting the default branch | |
| push: | |
| branches: | |
| - 'stable' | |
| # Do a dry-run (update, no deploy) for PRs. | |
| pull_request: | |
| # Allow running this workflow manually from the Actions tab. | |
| workflow_dispatch: | |
| # Allow this workflow to be triggered from outside. | |
| repository_dispatch: | |
| types: | |
| - 'phpcs-release' | |
| # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages | |
| permissions: | |
| contents: write | |
| pages: write | |
| id-token: write | |
| # Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. | |
| # However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. | |
| concurrency: | |
| group: "pages" | |
| cancel-in-progress: false | |
| jobs: | |
| update: | |
| name: "Update XSD files" | |
| # Don't run on forks. | |
| if: github.repository == 'PHPCSStandards/schema.phpcodesniffer.com' | |
| runs-on: ubuntu-latest | |
| steps: | |
| # By default use the `stable` branch. | |
| # For testing changes to the workflow or the scripts, use the PR branch | |
| # to have access to the latest version of the workflow/scripts. | |
| - name: Determine branch to use | |
| id: base_branch | |
| env: | |
| REF: ${{ github.ref }} | |
| run: | | |
| if [ "${{ github.event_name }}" == "pull_request" ]; then | |
| echo "BRANCH=$REF" >> "$GITHUB_OUTPUT" | |
| else | |
| echo 'BRANCH=stable' >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ steps.base_branch.outputs.BRANCH }} | |
| - name: Install PHP | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: '8.4' | |
| ini-values: error_reporting=-1, display_errors=On, log_errors_max_len=0 | |
| coverage: none | |
| - name: Get a list of the last 50 PHP_CodeSniffer releases | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: > | |
| gh release list --repo PHPCSStandards/PHP_CodeSniffer --limit=50 --order desc | |
| --json tagName,isPrerelease,isLatest,isDraft > releases.json | |
| - name: Update XSD files | |
| run: php ./src/update-site.php | |
| - name: Delete releases.json | |
| run: rm releases.json | |
| - name: "Debug info: check git status" | |
| run: git status -b -v -u | |
| # Commit all changed files back to the repository | |
| - name: Commit updated files | |
| uses: stefanzweifel/git-auto-commit-action@v6 | |
| with: | |
| commit_message: "Update XSD files" | |
| add_options: '-A' | |
| - name: Check GitHub Pages status | |
| uses: crazy-max/ghaction-github-status@v4 | |
| with: | |
| pages_threshold: major_outage | |
| - name: Setup Pages | |
| uses: actions/configure-pages@v5 | |
| - name: Upload static files as artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| # Upload _site directory only. | |
| path: _site/ | |
| deploy: | |
| needs: update | |
| # Don't run on forks. | |
| if: github.repository == 'PHPCSStandards/schema.phpcodesniffer.com' && github.event_name != 'pull_request' && needs.update.result == 'success' | |
| name: "Deploy the website" | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| steps: | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 |