22
22
default : " dist"
23
23
description : " Directory where the bundle should be unpacked"
24
24
type : string
25
- tree_hash :
25
+ deploy_hash :
26
26
required : true
27
27
description : " Tree hash of the code to deploy"
28
28
type : string
@@ -75,12 +75,12 @@ jobs:
75
75
- name : Check version already deployed
76
76
id : is-version-already-deployed
77
77
run : |
78
- DEPLOY_EXISTS=$(aws s3 ls s3://${{ inputs.bucket_name }}/html/${{ inputs.tree_hash }}/ || true)
78
+ DEPLOY_EXISTS=$(aws s3 ls s3://${{ inputs.bucket_name }}/html/${{ inputs.deploy_hash }}/ || true)
79
79
if [ -z "$DEPLOY_EXISTS" ]; then
80
- echo "Version ${{ inputs.tree_hash }} not yet deployed"
80
+ echo "Version ${{ inputs.deploy_hash }} not yet deployed"
81
81
echo "is_deployed=false" >> $GITHUB_OUTPUT
82
82
else
83
- echo "Version ${{ inputs.tree_hash }} already deployed"
83
+ echo "Version ${{ inputs.deploy_hash }} already deployed"
84
84
echo "is_deployed=true" >> $GITHUB_OUTPUT
85
85
fi
86
86
94
94
echo "Could not determine default branch"
95
95
exit 1
96
96
fi
97
- SUBDOMAIN=$([[ $GITHUB_REF = "refs/heads/$DEFAULT_BRANCH" || $GITHUB_REF = "refs/heads/change-freeze-emergency-deploy" ]] && echo "" || echo "preview-${{ inputs.tree_hash }}.")
97
+ SUBDOMAIN=$([[ $GITHUB_REF = "refs/heads/$DEFAULT_BRANCH" || $GITHUB_REF = "refs/heads/change-freeze-emergency-deploy" ]] && echo "" || echo "preview-${{ inputs.deploy_hash }}.")
98
98
echo "url=https://${SUBDOMAIN}${{ inputs.domain_name }}" >> $GITHUB_OUTPUT
99
99
100
100
- name : Setup AWS Credentials for Registry Bucket Access
@@ -124,7 +124,7 @@ jobs:
124
124
NODE_AUTH_TOKEN : ${{ secrets.GH_REGISTRY_NPM_TOKEN }}
125
125
SPA_BUNDLE_DIR : ${{ inputs.bundle_dir }}
126
126
SPA_ENV : ${{inputs.environment}}
127
- SPA_TREE_HASH : ${{ inputs.tree_hash }}
127
+ SPA_TREE_HASH : ${{ inputs.deploy_hash }}
128
128
run : ${{inputs.inject_config_cmd }}
129
129
130
130
- name : Copy Static Files
@@ -137,7 +137,7 @@ jobs:
137
137
- name : Copy HTML Files
138
138
if : ${{ steps.is-version-already-deployed.outputs.is_deployed == 'false'}}
139
139
run : |
140
- aws s3 cp ${{ inputs.bundle_dir }}/ s3://${{ inputs.bucket_name }}/html/${{ inputs.tree_hash }} \
140
+ aws s3 cp ${{ inputs.bundle_dir }}/ s3://${{ inputs.bucket_name }}/html/${{ inputs.deploy_hash }} \
141
141
--cache-control 'public,max-age=31536000,immutable' \
142
142
--recursive \
143
143
--exclude "static/*"
@@ -146,22 +146,29 @@ jobs:
146
146
if : ${{ steps.is-version-already-deployed.outputs.is_deployed == 'false'}}
147
147
run : |
148
148
aws s3 cp \
149
- s3://${{ inputs.bucket_name }}/html/${{ inputs.tree_hash }}/.well-known/apple-app-site-association \
150
- s3://${{ inputs.bucket_name }}/html/${{ inputs.tree_hash }}/.well-known/apple-app-site-association \
149
+ s3://${{ inputs.bucket_name }}/html/${{ inputs.deploy_hash }}/.well-known/apple-app-site-association \
150
+ s3://${{ inputs.bucket_name }}/html/${{ inputs.deploy_hash }}/.well-known/apple-app-site-association \
151
151
--content-type 'application/json' \
152
152
--cache-control 'public,max-age=3600' \
153
153
--metadata-directive REPLACE || echo "Failed updating .well-known files"
154
154
155
+ # We always copy deploy hash file even if we don't do an actual deployemnt as part of this commit
156
+ # This is used to identify which version of the deployed app is associated with the current commit
157
+ # In case we trigger rollback to this commit, we know what deployment to use based on the stored deploy_hash for this commit
158
+ - name : Copy Deploy Hash File
159
+ run : |
160
+ echo ${{ inputs.deploy_hash }} >> ${{ github.sha }}
161
+ aws s3 cp ${{ github.sha }} s3://${{ inputs.bucket_name }}/deploys/commits/${{ github.sha }}
162
+
155
163
- name : Update Cursor File
156
164
id : cursor-update
157
- uses : pleo-io/spa-tools/actions/cursor-deploy@2af7d6cdcd5fa8b0f2fec3034f6f04afd43ccde5
165
+ uses : pleo-io/spa-tools/actions/cursor-deploy@spa-github-actions-v10.0.0
158
166
if : ${{ steps.is-version-already-deployed.outputs.is_deployed == 'false'}}
159
167
with :
160
- custom_hash : ${{ inputs.tree_hash }}
161
168
bucket_name : ${{ inputs.bucket_name }}
162
169
163
170
- name : Update PR Description
164
- uses : pleo-io/spa-tools/actions/post-preview-urls@spa-github-actions-v9 .0.2
171
+ uses : pleo-io/spa-tools/actions/post-preview-urls@spa-github-actions-v10 .0.0
165
172
if : github.event_name == 'pull_request' && ${{ steps.is-version-already-deployed.outputs.is_deployed == 'false'}}
166
173
with :
167
174
app_name : ${{ inputs.app_name }}
@@ -176,4 +183,4 @@ jobs:
176
183
# We expect the injection to insert the version in the HTML.
177
184
run :
178
185
curl --silent --show-error ${{ steps.deployment-url.outputs.url }} |
179
- grep -q ${{ inputs.tree_hash }}
186
+ grep -q ${{ inputs.deploy_hash }}
0 commit comments