bot(ci): generate token list #85
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: Validate PR | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
jobs: | |
validate: | |
name: validate | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Use Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18.x | |
- name: Get changed files | |
id: changed-files | |
uses: tj-actions/changed-files@v39 | |
with: | |
dir_names: true | |
files: | | |
data/** | |
- name: List all changed tokens | |
id: changed_tokens | |
run: | | |
tokens="" | |
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do | |
token=$(echo -e "$file" | sed -nr "s|^data/([^/]*/?).*|\1|p") | |
tokens+="${token}," | |
done | |
echo "changed tokens: ${tokens%,*}" | |
echo "result=${tokens%,*}" >> $GITHUB_OUTPUT | |
- name: yarn install | |
if: ${{ steps.changed_tokens.outputs.result != '' }} | |
run: | | |
yarn install --frozen-lockfile | |
- name: Validate token list | |
if: ${{ steps.changed_tokens.outputs.result != '' }} | |
run: | | |
yarn validate ${{ steps.changed_tokens.outputs.result }} 2> err.txt 1> std.txt | |
- name: Print validation output | |
if: ${{ always() && steps.changed_tokens.outputs.result != '' }} | |
run: | | |
echo '=== std.txt ===' | |
cat std.txt | |
echo '=== err.txt ===' | |
cat err.txt |