|
40 | 40 | if: steps.node_modules_cache.outputs.cache-hit != 'true' |
41 | 41 | run: npm ci |
42 | 42 |
|
| 43 | + - name: Check if artifact exists |
| 44 | + id: check_node_modules_artifact |
| 45 | + run: | |
| 46 | + ARTIFACT_NAME="modern-node-modules-${{ hashFiles('**/package-lock.json') }}" |
| 47 | + ARTIFACT_EXISTS=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ |
| 48 | + "https://api.github.com/repos/${{ github.repository }}/actions/artifacts" | \ |
| 49 | + jq --arg name "$ARTIFACT_NAME" '.artifacts[] | select(.name == $name) | .id' | wc -l) |
| 50 | +
|
| 51 | + if [ "$ARTIFACT_EXISTS" -gt "0" ]; then |
| 52 | + echo "artifact_exists=true" >> $GITHUB_OUTPUT |
| 53 | + else |
| 54 | + echo "artifact_exists=false" >> $GITHUB_OUTPUT |
| 55 | + fi |
| 56 | +
|
| 57 | + - name: Upload node_modules to artifacts |
| 58 | + if: steps.check_node_modules_artifact.outputs.artifact_exists == 'false' |
| 59 | + uses: actions/upload-artifact@v4 |
| 60 | + with: |
| 61 | + name: modern-node-modules-${{ hashFiles('**/package-lock.json') }} |
| 62 | + path: node_modules |
| 63 | + |
43 | 64 | # This job is used to run tests on modern Node.js versions |
44 | 65 | # 1. Use default Node.js |
45 | 66 | # 2. Install latest dependencies |
|
63 | 84 | path: node_modules |
64 | 85 | key: ${{ runner.os }}-modern-node-modules-${{ hashFiles('**/package-lock.json') }} |
65 | 86 |
|
66 | | - - name: Check if artifact exists |
67 | | - id: check_node_modules_artifact |
68 | | - run: | |
69 | | - ARTIFACT_NAME="modern-node-modules-${{ hashFiles('**/package-lock.json') }}" |
70 | | - ARTIFACT_EXISTS=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ |
71 | | - "https://api.github.com/repos/${{ github.repository }}/actions/artifacts" | \ |
72 | | - jq --arg name "$ARTIFACT_NAME" '.artifacts[] | select(.name == $name) | .id' | wc -l) |
73 | | -
|
74 | | - if [ "$ARTIFACT_EXISTS" -gt "0" ]; then |
75 | | - echo "artifact_exists=true" >> $GITHUB_OUTPUT |
76 | | - else |
77 | | - echo "artifact_exists=false" >> $GITHUB_OUTPUT |
78 | | - fi |
79 | | -
|
80 | | - - name: Upload node_modules to artifacts |
81 | | - if: steps.check_node_modules_artifact.outputs.artifact_exists == 'false' |
82 | | - uses: actions/upload-artifact@v4 |
83 | | - with: |
84 | | - name: modern-node-modules-${{ hashFiles('**/package-lock.json') }} |
85 | | - path: node_modules |
86 | | - |
87 | 87 | - name: Build package |
88 | 88 | run: npm run build |
89 | 89 |
|
|
0 commit comments