|
9 | 9 | types: [published] |
10 | 10 |
|
11 | 11 | jobs: |
| 12 | + ts-modified: |
| 13 | + name: TS files changed |
| 14 | + if: github.event_name == 'pull_request' |
| 15 | + runs-on: ubuntu-latest |
| 16 | + outputs: |
| 17 | + ts_modified: ${{ steps.check-files.outputs.ts_modified }} |
| 18 | + steps: |
| 19 | + - name: Checkout repository |
| 20 | + uses: actions/checkout@v4 |
| 21 | + with: |
| 22 | + ref: ${{ github.event.pull_request.head.ref }} |
| 23 | + fetch-depth: 2 |
| 24 | + |
| 25 | + - name: Check for modified .ts files |
| 26 | + id: check-files |
| 27 | + run: | |
| 28 | + if git show --name-only --pretty="" ${{ github.event.pull_request.head.sha }} | grep -E "\.ts$"; then |
| 29 | + echo "ts_modified=true" >> $GITHUB_OUTPUT |
| 30 | + else |
| 31 | + echo "ts_modified=false" >> $GITHUB_OUTPUT |
| 32 | + fi |
| 33 | +
|
| 34 | + update-indices: |
| 35 | + name: Update indices |
| 36 | + needs: ts-modified |
| 37 | + if: needs.ts-modified.outputs.ts_modified == 'true' |
| 38 | + runs-on: ubuntu-latest |
| 39 | + outputs: |
| 40 | + has_changes: ${{ steps.check_changes.outputs.has_changes }} |
| 41 | + steps: |
| 42 | + - name: Checkout PR branch |
| 43 | + uses: actions/checkout@v4 |
| 44 | + with: |
| 45 | + ref: ${{ github.event.pull_request.head.ref }} |
| 46 | + token: ${{ secrets.BOT_GH_TOKEN }} |
| 47 | + |
| 48 | + - name: Generate indices |
| 49 | + run: ./generateIndices.sh |
| 50 | + |
| 51 | + - name: Check uncommitted indices |
| 52 | + id: check_changes |
| 53 | + run: | |
| 54 | + echo "has_changes=$([ -n "$(git diff --name-only HEAD "**/index.ts")" ] && echo "true" || echo "false")" >> $GITHUB_OUTPUT |
| 55 | +
|
| 56 | + - name: Commit indices |
| 57 | + if: steps.check_changes.outputs.has_changes == 'true' |
| 58 | + run: | |
| 59 | + echo "${{ secrets.BOT_PGP_KEY }}" | gpg --import --batch |
| 60 | + git config --global user.name "Cloudnode [bot]" |
| 61 | + git config --global user.email "[email protected]" |
| 62 | + git config --global user.signingkey "[email protected]" |
| 63 | + git add "**/index.ts" |
| 64 | + git commit -S -m "chore: update indices" |
| 65 | + git push |
| 66 | +
|
12 | 67 | build: |
13 | 68 | name: Build |
| 69 | + needs: update-indices |
| 70 | + if: always() && (needs.update-indices.outputs.has_changes == 'false' || needs.update-indices.result == 'skipped') |
14 | 71 | runs-on: ubuntu-latest |
15 | 72 | steps: |
16 | 73 | - name: Checkout repository |
|
40 | 97 | - name: Build |
41 | 98 | run: npm run build |
42 | 99 |
|
43 | | - - name: Check uncommitted indices |
44 | | - id: uncommitted_indices |
45 | | - if: github.event_name == 'pull_request' |
46 | | - run: | |
47 | | - echo "has_changes=$([ -n "$(git diff --name-only HEAD "**/index.ts")" ] && echo "true" || echo "false")" >> $GITHUB_OUTPUT |
48 | | -
|
49 | | - - name: Commit indices |
50 | | - if: github.event_name == 'pull_request' && steps.uncommitted_indices.outputs.has_changes == 'true' |
51 | | - run: | |
52 | | - echo "${{ secrets.BOT_PGP_KEY }}" | gpg --import --batch |
53 | | - git config --global user.signingkey "[email protected]" |
54 | | - git config --global user.name "Cloudnode [bot]" |
55 | | - git config --global user.email "[email protected]" |
56 | | - git add "**/index.ts" |
57 | | - git commit -S -m "chore: update indices" |
58 | | - git push |
59 | | -
|
60 | 100 | - name: Pack |
61 | 101 | run: npm pack |
62 | 102 |
|
|
68 | 108 | publish: |
69 | 109 | name: Publish |
70 | 110 | needs: build |
71 | | - if: github.event_name == 'release' |
| 111 | + if: always() && github.event_name == 'release' |
72 | 112 | runs-on: ubuntu-latest |
73 | 113 | permissions: |
74 | 114 | contents: read |
|
0 commit comments