Merge pull request #1271 from PHPCSStandards/feature/ghactions-improv… #19
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 gh-pages branch to GitHub Pages | |
on: | |
push: | |
branches: | |
- "gh-pages" | |
# Do a dry-run (update, no deploy) for PRs. | |
pull_request: | |
# Allow running this workflow manually from the Actions tab. | |
workflow_dispatch: | |
permissions: {} | |
# 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: | |
build: | |
# Don't run on forks. | |
if: github.event.repository.fork == false | |
name: "Build the website" | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read # to read the contents of the repo | |
steps: | |
# By default use the `gh-pages` 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=gh-pages' >> "$GITHUB_OUTPUT" | |
fi | |
- name: Checkout code | |
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
with: | |
ref: ${{ steps.base_branch.outputs.BRANCH }} | |
persist-credentials: false | |
- name: Install PHP | |
uses: shivammathur/setup-php@ec406be512d7077f68eed36e63f4d91bc006edc4 # 2.35.4 | |
with: | |
php-version: '8.4' | |
ini-values: error_reporting=-1, display_errors=On, display_startup_errors=On, log_errors_max_len=0 | |
coverage: none | |
- name: Generate /phars/index.html | |
run: php build/generate_phars_list.php | |
- name: Check GitHub Pages status | |
uses: crazy-max/ghaction-github-status@fa6ac37620bc5d44b93e15caed498629665e9ff5 # v4.2.0 | |
with: | |
pages_threshold: major_outage | |
- name: Setup Pages | |
uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b # v5.0.0 | |
- name: Upload artifact | |
uses: actions/upload-pages-artifact@7b1f4a764d45c48632c6b24a0339c27f5614fb0b # v4.0.0 | |
with: | |
path: './src' | |
deploy: | |
needs: build | |
# Don't run on forks. | |
if: github.repository == 'PHPCSStandards/PHP_CodeSniffer' && github.event_name != 'pull_request' && needs.build.result == 'success' | |
name: "Deploy the website" | |
runs-on: ubuntu-latest | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
permissions: | |
pages: write # to deploy to Pages | |
id-token: write # to verify the deployment originates from an appropriate source | |
steps: | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4.0.5 |