Skip to content

Commit ae43916

Browse files
committed
Include appbuilder version in project cache key
1 parent 59ef743 commit ae43916

1 file changed

Lines changed: 18 additions & 26 deletions

File tree

.github/workflows/main.yml

Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,12 @@ on:
77
branches: ['*']
88

99
jobs:
10-
check-appbuilders-version:
11-
runs-on: ubuntu-latest
12-
13-
steps:
14-
- uses: actions/checkout@v4
15-
16-
- name: Get AppBuilder Version
17-
run: |
18-
# Get tag from GHCR
19-
TOKEN_JSON=$(curl https://ghcr.io/token\?scope\="repository:sillsdev/app-builders:pull")
20-
TOKEN=$(echo "$TOKEN_JSON" | jq -r ".token")
21-
TAG_DATA=$(curl -H "Authorization: Bearer $TOKEN" https://ghcr.io/v2/sillsdev/app-builders/tags/list)
22-
NUM_TAGS=$(echo "$TAG_DATA" | jq -r '.tags | length')
23-
FROM_GHCR=$(echo "$TAG_DATA" | jq -r ".tags[$(("$NUM_TAGS" - 1))]")
24-
echo "Latest tag of sillsdev/app-builders is: $FROM_GHCR"
25-
# Get version from package.json
26-
FROM_PACKAGE=$(jq -r ".version" "package.json")
27-
echo "Latest version of sillsdev/appbuilder-pwa is: $FROM_PACKAGE"
28-
if [ "$FROM_GHCR" != "$FROM_PACKAGE" ]; then
29-
echo "version in package.json does not match latest version from ghcr"
30-
exit 1
31-
fi
32-
3310
setup:
3411
runs-on: ubuntu-latest
3512

13+
outputs:
14+
appbuilder_version: ${{ steps.get_version.outputs.appbuilder_version }}
15+
3616
steps:
3717
- uses: actions/checkout@v4
3818

@@ -63,12 +43,24 @@ jobs:
6343
path: node_modules
6444
key: ${{ runner.os }}-node-modules-${{ hashFiles('package-lock.json') }}
6545

46+
- name: Get AppBuilder Version
47+
id: get_version
48+
run: |
49+
# Get tag from GHCR
50+
TOKEN_JSON=$(curl https://ghcr.io/token\?scope\="repository:sillsdev/app-builders:pull")
51+
TOKEN=$(echo "$TOKEN_JSON" | jq -r ".token")
52+
TAG_DATA=$(curl -H "Authorization: Bearer $TOKEN" https://ghcr.io/v2/sillsdev/app-builders/tags/list)
53+
NUM_TAGS=$(echo "$TAG_DATA" | jq -r '.tags | length')
54+
FROM_GHCR=$(echo "$TAG_DATA" | jq -r ".tags[$(("$NUM_TAGS" - 1))]")
55+
echo "Latest tag of sillsdev/app-builders is: $FROM_GHCR"
56+
echo "appbuilder_version=$FROM_GHCR" >> $GITHUB_OUTPUT
57+
6658
- name: Restore Projects cache
6759
id: restore-projects-cache
6860
uses: actions/cache@v4
6961
with:
7062
path: project_data
71-
key: ${{ runner.os }}-projects-${{ hashFiles('test_data/projects', 'convert/*.ts') }}
63+
key: ${{ runner.os }}-projects-${{ hashFiles('test_data/projects', 'convert/*.ts') }}-${{ steps.get_version.outputs.appbuilder_version }}
7264

7365
- name: Setup Java
7466
if: steps.restore-projects-cache.outputs.cache-hit != 'true'
@@ -163,7 +155,7 @@ jobs:
163155
uses: actions/cache@v4
164156
with:
165157
path: project_data
166-
key: ${{ runner.os }}-projects-${{ hashFiles('test_data/projects', 'convert/*.ts') }}
158+
key: ${{ runner.os }}-projects-${{ hashFiles('test_data/projects', 'convert/*.ts') }}-${{ needs.setup.outputs.appbuilder_version }}
167159

168160
- name: Convert minimal project
169161
run: |
@@ -203,7 +195,7 @@ jobs:
203195
uses: actions/cache@v4
204196
with:
205197
path: project_data
206-
key: ${{ runner.os }}-projects-${{ hashFiles('test_data/projects', 'convert/*.ts') }}
198+
key: ${{ runner.os }}-projects-${{ hashFiles('test_data/projects', 'convert/*.ts') }}-${{ needs.setup.outputs.appbuilder_version }}
207199

208200
- name: Run Tests
209201
run: |

0 commit comments

Comments
 (0)