Skip to content

Commit

Permalink
better caching for npm packages; default token
Browse files Browse the repository at this point in the history
  • Loading branch information
UlyssesZh committed Nov 10, 2024
1 parent fae1ea3 commit 0130caa
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 26 deletions.
27 changes: 19 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ on:
jobs:
generate:
name: Generate
runs-on: ubuntu-latest
strategy:
matrix:
platform: [windows-latest, ubuntu-latest, macos-latest]
runs-on: ${{ matrix.platform }}

steps:
- name: Checkout
Expand All @@ -20,14 +23,12 @@ jobs:
with:
card: stats
options: username=${{ github.repository_owner }}
path: grs/stats.svg
env:
PAT_1: ${{ secrets.GITHUB_TOKEN }}
path: grs/stats-${{ matrix.platform }}.svg

- name: Upload
uses: actions/upload-artifact@v4
with:
name: stats
name: stats-${{ matrix.platform }}
path: grs

push:
Expand All @@ -37,12 +38,22 @@ jobs:
needs: generate

steps:
- name: Download
- name: Download (Ubuntu)
uses: actions/download-artifact@v4
with:
name: stats
name: stats-ubuntu-latest
path: grs


- name: Download (Windows)
uses: actions/download-artifact@v4
with:
name: stats-windows-latest

- name: Download (macOS)
uses: actions/download-artifact@v4
with:
name: stats-macos-latest

- name: Push
uses: crazy-max/ghaction-github-pages@v4
with:
Expand Down
18 changes: 11 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,23 @@ Example usage:
uses: UlyssesZh/grs-action@v0
with:
card: stats
options: username=${{ github.repository_owner }}
options: username=${{ github.repository_owner }}&hide_border=true
path: grs/stats.svg
env:
PAT_1: ${{ secrets.GITHUB_TOKEN }}
```
For a more complicated example, see
[my own profile](https://github.com/ulysseszh/ulysseszh/blob/master/.github/workflows/grs.yml).
## Inputs
- `card`: The type of card to generate. Can be `stats` (default), `repo`, `langs`, `wakatime`, or `gist`.
- `options`: The options to pass to the card. For example, `username=UlyssesZh`.
- `path`: The path to save the generated card to. Defaults to `grs/out.svg`.
- `card`: The type of card to generate.
Can be `stats` (default), `repo`, `langs`, `wakatime`, or `gist`.
- `options`: The options to pass to the card. For example, `username=UlyssesZh&hide_border=true`.
Defaults to `username=${{github.repository_owner}}`.
- `path`: The path to save the generated card to.
Defaults to `grs/out.svg`.
- `token`: The GitHub token to use for fetching data. Normally no need to set this.

Environment variables:

- `PAT_1`: GitHub token, required.
- `FETCH_MULTI_PAGE_STARS`: experimental multi-page fetching.
30 changes: 19 additions & 11 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,41 +1,49 @@
name: 'GitHub README stats generator'
description: 'Dynamically generated stats for your GitHub README'
name: GitHub README stats generator
description: Dynamically generated stats for your GitHub README
inputs:
card:
description: 'Type of card: stats (default), repo, langs, or wakatime'
description: 'Type of card: one of stats (default), repo, langs, wakatime, gist.'
required: false
default: 'stats'
default: stats
options:
description: 'Options for the card'
required: true
description: Options for the card
required: false
default: username=${{ github.repository_owner }}
path:
description: 'Output path for SVG file (relative path; include filename with .svg)'
description: Output path for SVG file (relative path; include filename with .svg)
required: false
default: grs/out.svg
token:
description: GitHub token; normally no need to set it
required: false
default: 'grs/out.svg'
default: ${{ github.server_url == 'https://github.com' && github.token || '' }}
runs:
using: composite
steps:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: npm
cache-dependency-path: ${{ github.action_path }}/package-lock.json
- name: CI
run: |
cd $GITHUB_ACTION_PATH
npm ci
cd $GITHUB_WORKSPACE
env:
GITHUB_ACTION_PATH: ${{ github.action_path }}
GITHUB_WORKSPACE: ${{ github.workspace }}
shell: bash
- name: Run
run: |
cd $GITHUB_WORKSPACE
node $GITHUB_ACTION_PATH/index.js
run: node $GITHUB_ACTION_PATH/index.js
env:
GITHUB_WORKSPACE: ${{ github.workspace }}
GITHUB_ACTION_PATH: ${{ github.action_path }}
GRS_CARD: ${{ inputs.card }}
GRS_OPTIONS: ${{ inputs.options }}
GRS_PATH: ${{ inputs.path }}
PAT_1: ${{ inputs.token }}
shell: bash
branding:
color: 'green'
Expand Down

0 comments on commit 0130caa

Please sign in to comment.