Skip to content

Commit 5ce17ba

Browse files
authored
chore: Only cache dependencies on main builds (#3171)
1 parent df39b06 commit 5ce17ba

File tree

1 file changed

+27
-6
lines changed

1 file changed

+27
-6
lines changed

.github/workflows/build_amplify_swift.yml

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,11 @@ jobs:
5858
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 #v3.5.3
5959
with:
6060
persist-credentials: false
61-
- name: Cache packages
61+
- name: Attempt to restore dependencies cache
6262
id: cache-packages
6363
timeout-minutes: 4
64-
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
64+
continue-on-error: true
65+
uses: actions/cache/restore@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
6566
with:
6667
path: ~/Library/Developer/Xcode/DerivedData/Amplify
6768
key: amplify-packages-${{ hashFiles('Package.resolved') }}
@@ -76,6 +77,12 @@ jobs:
7677
xcode_path: '/Applications/Xcode_14.3.app'
7778
disable_package_resolution: ${{ steps.cache-packages.outputs.cache-hit }}
7879
other_flags: '-derivedDataPath Build -clonedSourcePackagesDirPath ~/Library/Developer/Xcode/DerivedData/Amplify'
80+
- name: Save the dependencies cache if necessary
81+
if: steps.cache-packages.outputs.cache-hit != 'true' && github.ref_name == 'main'
82+
uses: actions/cache/save@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
83+
with:
84+
path: ~/Library/Developer/Xcode/DerivedData/Amplify
85+
key: ${{ steps.cache-packages.outputs.cache-primary-key }}
7986

8087
build-amplify-swift-tvOS:
8188
runs-on: macos-13
@@ -84,10 +91,11 @@ jobs:
8491
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 #v3.5.3
8592
with:
8693
persist-credentials: false
87-
- name: Cache packages
94+
- name: Attempt to restore dependencies cache
8895
timeout-minutes: 4
8996
id: cache-packages
90-
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
97+
continue-on-error: true
98+
uses: actions/cache/restore@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
9199
with:
92100
path: ~/Library/Developer/Xcode/DerivedData/Amplify
93101
key: amplify-packages-${{ hashFiles('Package.resolved') }}
@@ -102,6 +110,12 @@ jobs:
102110
xcode_path: '/Applications/Xcode_14.3.app'
103111
disable_package_resolution: ${{ steps.cache-packages.outputs.cache-hit }}
104112
other_flags: '-derivedDataPath Build -clonedSourcePackagesDirPath ~/Library/Developer/Xcode/DerivedData/Amplify'
113+
- name: Save the dependencies cache if necessary
114+
if: steps.cache-packages.outputs.cache-hit != 'true' && github.ref_name == 'main'
115+
uses: actions/cache/save@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
116+
with:
117+
path: ~/Library/Developer/Xcode/DerivedData/Amplify
118+
key: ${{ steps.cache-packages.outputs.cache-primary-key }}
105119

106120
build-amplify-swift-watchOS:
107121
runs-on: macos-13
@@ -110,10 +124,11 @@ jobs:
110124
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 #v3.5.3
111125
with:
112126
persist-credentials: false
113-
- name: Cache packages
127+
- name: Attempt to restore dependencies cache
114128
id: cache-packages
115129
timeout-minutes: 4
116-
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
130+
continue-on-error: true
131+
uses: actions/cache/restore@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
117132
with:
118133
path: ~/Library/Developer/Xcode/DerivedData/Amplify
119134
key: amplify-packages-${{ hashFiles('Package.resolved') }}
@@ -128,6 +143,12 @@ jobs:
128143
xcode_path: '/Applications/Xcode_14.3.app'
129144
disable_package_resolution: ${{ steps.cache-packages.outputs.cache-hit }}
130145
other_flags: '-derivedDataPath Build -clonedSourcePackagesDirPath ~/Library/Developer/Xcode/DerivedData/Amplify'
146+
- name: Save the dependencies cache if necessary
147+
if: steps.cache-packages.outputs.cache-hit != 'true' && github.ref_name == 'main'
148+
uses: actions/cache/save@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
149+
with:
150+
path: ~/Library/Developer/Xcode/DerivedData/Amplify
151+
key: ${{ steps.cache-packages.outputs.cache-primary-key }}
131152

132153
confirm-pass:
133154
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)