Skip to content

feat: introduce o-private-foundation #2998

feat: introduce o-private-foundation

feat: introduce o-private-foundation #2998

Workflow file for this run

name: percy
concurrency:
group: ${{ github.head_ref }}-${{ github.workflow }}
cancel-in-progress: true
on:
pull_request:
types:
- opened
- reopened
- synchronize
- labeled
paths:
- "package.json"
- "package-lock.json"
- "components/**"
- "!components/**/*.md"
- "!components/o3-*/**"
push:
branches: main
paths:
- "package.json"
- "package-lock.json"
- "components/**"
- "!components/**/*.md"
- "!components/o3-*/**"
jobs:
changes:
runs-on: ubuntu-latest
permissions:
pull-requests: read
outputs:
components: ${{ steps.set-matrix.outputs.changes }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: volta-cli/action@v4
- uses: actions/cache@v2
with:
volta-version: "1.0.8"
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Configure Cloudsmith
env:
CLOUDSMITH_API_KEY: ${{ secrets.CLOUDSMITH_API_KEY }}
run: |
npm config set registry=https://npm.packages.ft.com/financial-times-internal-releases/
npm config set //npm.packages.ft.com/financial-times-internal-releases/:_authToken=${CLOUDSMITH_API_KEY}
- name: Install node modules
run: npm ci
- name: Find components affected by changes
id: percy-changes
run: |
changes=()
for component in components/*/; do
RESULT=$(WORKSPACE=$component node ./scripts/should-percy-run.js | grep "\-RESULT:" | cut -d ":" -f 2)
component_trimmed=$(echo $component | sed 's/\/$//g')
if [[ $RESULT = 'true' ]]; then
echo "$component_trimmed is affected by changes, adding to percy run list."
changes+=("$component_trimmed")
fi
done
json_array=$(jq -n '$ARGS.positional' --args "${changes[@]}");
echo "Changes:\n$json_array:";
echo "CHANGES=$(echo ${json_array})" >> "$GITHUB_OUTPUT";
- name: Set Matrix
id: set-matrix
run: |
CHANGES_INPUT=$(echo '${{ steps.percy-changes.outputs.changes }}')
if [ $CHANGES_INPUT -ne "[]"]; then
MATRIX=$(echo $CHANGES_INPUT | jq '{include: (map({component: ., token_name: ("PERCY_TOKEN_" + (. | ascii_upcase | sub("(/|-)"; "_"; "g")))}))}' | tr '\n' ' ')
echo "CHANGES=$(echo "$MATRIX")" >> "$GITHUB_OUTPUT";
else
echo "CHANGES=$(echo '[]')" >> "$GITHUB_OUTPUT";
fi
run-percy:
if: ${{ needs.changes.outputs.components != '[]' && needs.changes.outputs.components != '' }}
needs: changes
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.changes.outputs.components) }}
steps:
- uses: actions/checkout@v2
- uses: volta-cli/action@v4
- uses: actions/cache@v2
with:
volta-version: "1.0.8"
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Configure Cloudsmith
env:
CLOUDSMITH_API_KEY: ${{ secrets.CLOUDSMITH_API_KEY }}
run: |
npm config set registry=https://npm.packages.ft.com/financial-times-internal-releases/
npm config set //npm.packages.ft.com/financial-times-internal-releases/:_authToken=${CLOUDSMITH_API_KEY}
- name: Install node modules
run: npm ci
- name: Start Percy check
env:
PERCY_TOKEN: ${{ secrets[matrix.token_name] }}
WORKSPACE: ${{ matrix.component }}
run: |
node ./scripts/percy.js