diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3302c99..ea475fb 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -3,6 +3,12 @@ on: pull_request: push: branches: [master] + +permissions: + contents: read + pages: write + id-token: write + jobs: test: name: Ruby ${{ matrix.ruby }} / Rails ${{ matrix.rails }} / AA ${{ matrix.activeadmin }} / SQLite @@ -108,3 +114,49 @@ jobs: with: name: coverage path: coverage/ + + - name: Generate badge.json + run: | + LAST_RUN="coverage/.last_run.json" + if [ ! -f "$LAST_RUN" ]; then + mkdir -p badge + echo '{"schemaVersion":1,"label":"coverage","message":"unknown","color":"lightgrey"}' > badge/badge.json + exit 0 + fi + PERCENT=$(ruby -rjson -e "puts JSON.parse(File.read('$LAST_RUN')).dig('result','line').round(1)") + PERCENT_NUM=$(ruby -rjson -e "puts JSON.parse(File.read('$LAST_RUN')).dig('result','line')") + if ruby -e "exit(($PERCENT_NUM >= 90) ? 0 : 1)"; then COLOR="brightgreen" + elif ruby -e "exit(($PERCENT_NUM >= 75) ? 0 : 1)"; then COLOR="green" + elif ruby -e "exit(($PERCENT_NUM >= 60) ? 0 : 1)"; then COLOR="yellow" + else COLOR="red"; fi + mkdir -p badge + echo "{\"schemaVersion\":1,\"label\":\"coverage\",\"message\":\"${PERCENT}%\",\"color\":\"${COLOR}\"}" > badge/badge.json + + - name: Upload badge artifact + uses: actions/upload-artifact@v4 + with: + name: coverage-badge + path: badge + + deploy-coverage: + needs: coverage + if: github.ref == 'refs/heads/master' && github.event_name == 'push' + runs-on: ubuntu-latest + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + steps: + - name: Download coverage badge + uses: actions/download-artifact@v4 + with: + name: coverage-badge + path: . + - name: Setup Pages + uses: actions/configure-pages@v5 + - name: Upload Pages artifact + uses: actions/upload-pages-artifact@v3 + with: + path: . + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 diff --git a/README.md b/README.md index b81a632..601954f 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ # ActiveAdminImport -[![Build Status ][build_badge]][build_link] -[![Coverage Status][coveralls_badge]][coveralls_link] -[![Code Climate ][codeclimate_badge]][codeclimate_link] -[![Gem Version ][rubygems_badge]][rubygems_link] -[![License ][license_badge]][license_link] +[![Build Status][build_badge]][build_link] +![Coverage][coverage_badge] +[![Code Climate][codeclimate_badge]][codeclimate_link] +[![Gem Version][rubygems_badge]][rubygems_link] +[![License][license_badge]][license_link] The fastest and most efficient CSV import for Active Admin with support for validations, bulk inserts, and encoding handling. @@ -331,8 +331,7 @@ Tool | Description [build_badge]: https://github.com/activeadmin-plugins/active_admin_import/actions/workflows/test.yml/badge.svg [build_link]: https://github.com/activeadmin-plugins/active_admin_import/actions -[coveralls_badge]: https://coveralls.io/repos/activeadmin-plugins/active_admin_import/badge.svg -[coveralls_link]: https://coveralls.io/github/activeadmin-plugins/active_admin_import +[coverage_badge]: https://img.shields.io/endpoint?url=https://activeadmin-plugins.github.io/active_admin_import/badge.json [codeclimate_badge]: https://codeclimate.com/github/activeadmin-plugins/active_admin_import/badges/gpa.svg [codeclimate_link]: https://codeclimate.com/github/activeadmin-plugins/active_admin_import [rubygems_badge]: https://badge.fury.io/rb/active_admin_import.svg