-
-
Notifications
You must be signed in to change notification settings - Fork 11
66 lines (59 loc) · 2.47 KB
/
quarto-web.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
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