Get Extensions from Quarto Website #38
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: Get Extensions from Quarto Website | |
on: | |
schedule: | |
- cron: '0 1 * * 0' | |
workflow_dispatch: | |
jobs: | |
quarto-web: | |
runs-on: ubuntu-latest | |
env: | |
GH_TOKEN: ${{ secrets.github_token }} | |
BRANCH: ci/get-quarto-web-extensions | |
COMMIT: "ci: get quarto-web extensions" | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Git Config | |
shell: bash | |
run: | | |
git config --local user.name github-actions[bot] | |
git config --local user.email 41898282+github-actions[bot]@users.noreply.github.com | |
- name: Get extensions from Quarto Website and commit | |
shell: bash | |
run: | | |
CSV_FILE="extensions/quarto-extensions.csv" | |
git clone --quiet --filter=blob:none --no-checkout https://github.com/quarto-dev/quarto-web _quarto-web | |
git -C _quarto-web sparse-checkout init --cone | |
git -C _quarto-web sparse-checkout set docs/extensions/listings | |
git -C _quarto-web checkout main --quiet | |
find _quarto-web/docs/extensions/listings -type f -name "*.yml" ! -name "_*" \ | |
-exec grep -o 'path: https://github.com/.*' {} \; \ | |
| sed 's/path: https:\/\/github.com\///' | sed 's/blob\/[^/]*\///' > _quarto-web/quarto-web-extensions.csv | |
cat "${CSV_FILE}" > _quarto-web/quarto-extensions.csv | |
echo "gadenbuie/countdown" >> _quarto-web/quarto-extensions.csv | |
extensions_to_add=$(grep -Fvxi -f _quarto-web/quarto-extensions.csv _quarto-web/quarto-web-extensions.csv || true) | |
rm -rf _quarto-web | |
if [[ -z "${extensions_to_add}" ]]; then | |
echo "No new extensions to add." | |
exit 0 | |
fi | |
if git show-ref --quiet refs/heads/${{ env.BRANCH }}; then | |
echo "Branch ${{ env.BRANCH }} already exists." | |
git branch -D "${{ env.BRANCH }}" | |
git push origin --delete "${{ env.BRANCH }}" | |
fi | |
git checkout -b "${{ env.BRANCH }}" | |
echo "${extensions_to_add}" >> "${CSV_FILE}" | |
git add "${CSV_FILE}" | |
git commit -m "${{ env.COMMIT }}" | |
git push --force origin ${{ env.BRANCH }} | |
gh pr create \ | |
--fill-first \ | |
--base "main" \ | |
--head "${{ env.BRANCH }}" \ | |
--label "Type: CI/CD :robot:" \ | |
--reviewer "${{ github.repository_owner }}" | |
- name: Merge Pull Request | |
if: false | |
shell: bash | |
run: | | |
gh pr merge --auto --squash --delete-branch |