|
| 1 | +name: Percy Github Integration |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: [ "main" ] |
| 5 | + pull_request: |
| 6 | + branches: [ "main" ] |
| 7 | + workflow_dispatch: |
| 8 | + # Optional: You can define inputs here that the user can provide |
| 9 | + # when triggering manually via the UI. |
| 10 | + # inputs: |
| 11 | + # environment: |
| 12 | + # description: 'Environment to deploy to' |
| 13 | + # required: true |
| 14 | + # default: 'staging' |
| 15 | + # build_only: |
| 16 | + # description: 'Skip deployment steps?' |
| 17 | + # required: false |
| 18 | + # type: boolean |
| 19 | + # default: false |
| 20 | +jobs: |
| 21 | + test: |
| 22 | + runs-on: ubuntu-latest |
| 23 | + steps: |
| 24 | + - uses: actions/checkout@v4 |
| 25 | + - uses: actions/setup-node@v4 |
| 26 | + with: |
| 27 | + node-version: 20 |
| 28 | + - uses: actions/cache@v4 |
| 29 | + with: |
| 30 | + path: ~/.npm |
| 31 | + key: v1/${{ runner.os }}/node-14/${{ hashFiles('**/package-lock.lock') }} |
| 32 | + restore-keys: v1/${{ runner.os }}/node-14/ |
| 33 | + - name: Install dependencies |
| 34 | + run: npm install |
| 35 | + - name: Run tests |
| 36 | + #run: npm test |
| 37 | + run: | |
| 38 | + BUILD_ID=$(npx percy storybook:start | grep https:\/\/percy.io\/.*\/builds | awk -F "/" '{print $NF}') |
| 39 | + # Check if an ID was found and set the environment variable |
| 40 | + if [ -n "$BUILD_ID" ]; then |
| 41 | + echo "Successfully extracted Percy Build ID: $BUILD_ID" |
| 42 | + # Set the environment variable PERCY_BUILD_ID for subsequent steps |
| 43 | + echo "PERCY_BUILD_ID=$BUILD_ID" >> $GITHUB_ENV |
| 44 | + else |
| 45 | + echo "Error: Could not extract Percy Build ID from Percy command output." |
| 46 | + fi |
| 47 | + env: |
| 48 | + PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }} |
| 49 | + - name: List files in current directory |
| 50 | + run: ls -al |
| 51 | + - name: Make script executable |
| 52 | + run: chmod +x ./waitForBuildT0End.sh |
| 53 | + |
| 54 | + - name: Execute the script file |
| 55 | + run: ./waitForBuildT0End.sh |
| 56 | + env: |
| 57 | + PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }} |
| 58 | + PERCY_BUILD_ID: ${{ env.PERCY_BUILD_ID }} |
0 commit comments