Fetch GitHub data and rebuild dashboard #50190
This file contains 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: Fetch GitHub data and rebuild dashboard | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: '*/20 * * * *' # Run every 20 minutes. | |
# Cancels all previous workflow runs for the same branch that have not yet completed. | |
concurrency: | |
# The concurrency group contains the workflow name and the branch name. | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
fetch-github-data: | |
name: Fetch GitHub data | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out source code | |
uses: actions/checkout@v3 | |
- name: Set up PHP envirnoment | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: '8.0' | |
env: | |
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Check existence of composer.json file | |
id: check_composer_file | |
uses: andstor/file-existence-action@v2 | |
with: | |
files: "composer.json" | |
- name: Install Composer dependencies & cache dependencies | |
if: steps.check_composer_file.outputs.files_exists == 'true' | |
uses: "ramsey/composer-install@v2" | |
env: | |
COMPOSER_ROOT_VERSION: dev-${{ github.event.repository.default_branch }} | |
- name: Configure git user | |
run: | | |
git config --global user.email "info@wp-cli.org" | |
git config --global user.name "wp-make-coffee" | |
- name: Install WP-CLI | |
run: | | |
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli-nightly.phar | |
sudo mv wp-cli-nightly.phar /usr/local/bin/wp | |
sudo chmod +x /usr/local/bin/wp | |
- name: Fetch GitHub data | |
run: | | |
wp dashboard fetch-github-data | |
env: | |
GITHUB_TOKEN: ${{ secrets.MAKE_COFFEE_TOKEN }} | |
- name: Rebuild dashboard | |
run: | | |
wp dashboard build | |
- name: Check if there are changes | |
run: echo "CHANGES_DETECTED=$([[ -z $(git status --porcelain) ]] && echo "0" || echo "1")" >> $GITHUB_ENV | |
- name: Commit changes | |
if: env.CHANGES_DETECTED == 1 | |
run: | | |
git add github-data index.html | |
git commit -m "Fetch GitHub data and rebuild dashboard - $(date +'%Y-%m-%d-%H-%M-%S')" | |
git push origin |