Refresh data sources #157
This file contains hidden or 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: Refresh data sources | |
| on: | |
| schedule: | |
| - cron: "0 14 * * *" | |
| workflow_dispatch: | |
| env: | |
| package_dir: "/" | |
| jobs: | |
| refresh-data-sources: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| id-token: write | |
| steps: | |
| - uses: actions/checkout@v2 | |
| - uses: actions/setup-node@v2 | |
| with: | |
| node-version: "22" | |
| registry-url: "https://registry.npmjs.org" | |
| - name: Install environment | |
| run: npm ci | |
| - name: check for BCD and web-features updates | |
| id: update-bcd-and-web-features | |
| run: npm run update-data-dependencies | |
| - name: Run refresh-downstream.ts | |
| if: steps.update-bcd-and-web-features.outcome == 'success' | |
| id: refresh-downstream-script | |
| run: npm run refresh-downstream ${{ secrets.USERAGENTSIOKEY }} | |
| - name: Attempt to update data.js file | |
| if: steps.refresh-downstream-script.outcome == 'success' | |
| id: update-data-file | |
| run: npm run update-data-file | |
| - name: Check for changes to ./src/data/data.js | |
| if: steps.update-data-file.outcome == 'success' | |
| id: check-data-changes | |
| run: npm run check-data-changes -s >> $GITHUB_OUTPUT | |
| - name: Run tests and linting | |
| if: steps.check-data-changes.outputs.changes-available == 'TRUE' | |
| id: lint-and-test | |
| run: npm run test | |
| - name: Push changes to main | |
| if: steps.lint-and-test.outcome == 'success' | |
| id: push-to-branch | |
| run: | | |
| echo "Data changes have occurred, committing to main" | |
| git config --global user.name 'github-actions[bot]' | |
| git config --global user.email 'github-actions[bot]@users.noreply.github.com' | |
| git add . | |
| git commit -m "Browser or feature data changed" | |
| git push origin | |
| - name: Tag release for publishing | |
| if: steps.push-to-branch.outcome == 'success' | |
| id: tag-release | |
| run: | | |
| npm version patch -m "Patch to %s because browser or feature data changed" | |
| git push && git push --tags | |
| - name: Build for release | |
| if: steps.tag-release.outcome == 'success' | |
| id: build | |
| run: npm run build | |
| - name: Publish new version to NPM | |
| id: publish-to-npm | |
| if: steps.build.outcome == 'success' | |
| run: | | |
| echo "publishing" | |
| npm publish --provenance --access public | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |