update #8729
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: update | |
on: | |
push: | |
branches: | |
- main | |
schedule: | |
# every hour | |
- cron: '0 * * * *' | |
jobs: | |
scrape: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
# install dependencies and run scraper | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: '18' | |
- name: scrape | |
working-directory: scraper | |
run: | | |
npm ci | |
npm start | |
# upload scraped css as artifact | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: css | |
path: css | |
dump: | |
runs-on: ubuntu-latest | |
needs: scrape | |
steps: | |
- uses: actions/checkout@v4 | |
# download scraped css | |
- uses: actions/download-artifact@v3 | |
with: | |
name: css | |
path: css | |
# install dependencies and run dumper | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: '18' | |
- name: dump | |
working-directory: dumper | |
run: | | |
npm start | |
# upload dumped classes as artifact | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: dump | |
path: dump | |
commit: | |
runs-on: ubuntu-latest | |
needs: dump | |
outputs: | |
diff: ${{ steps.check_diff.outputs.diff }} | |
steps: | |
- uses: actions/checkout@v4 | |
# download dumped classes | |
- uses: actions/download-artifact@v3 | |
with: | |
name: dump | |
path: dump | |
# check if there are any changes | |
- name: check diff | |
id: check_diff | |
run: | | |
if git diff --quiet; then | |
echo 'diff=false' >> $GITHUB_OUTPUT | |
else | |
echo 'diff=true' >> $GITHUB_OUTPUT | |
fi | |
# commit and push changes | |
- name: commit dump | |
run: | | |
if [ '${{ steps.check_diff.outputs.diff }}' == 'true' ]; then | |
git config --global user.name 'GitHub Actions' | |
git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com' | |
git commit -am 'routine dump' | |
git push | |
fi | |
publish: | |
runs-on: ubuntu-latest | |
needs: commit | |
if: ${{ needs.commit.outputs.diff == 'true' }} | |
steps: | |
- uses: actions/checkout@v4 | |
# publish updated package to npm | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: '18' | |
registry-url: 'https://registry.npmjs.org' | |
- name: publish | |
run: | | |
git config --global user.name 'GitHub Actions' | |
git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com' | |
npm version patch | |
git pull --rebase | |
git push | |
npm publish | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |