Get Extensions from Quarto Website #33
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\///' > _quarto-web/quarto-web-extensions.csv | |
cat "${CSV_FILE}" | cut -d'/' -f1,2 > _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 |