about summary refs log tree commit diff
path: root/.github
diff options
context:
space:
mode:
authorHailey <me@haileyok.com>2024-04-05 08:27:22 -0700
committerGitHub <noreply@github.com>2024-04-05 08:27:22 -0700
commit443dfb5c3e9438932bd61e754a01197604d03188 (patch)
tree27c7a3ec85e87b60aaf69a25b40e3d4cda73959b /.github
parent46c112edfdcb40681a8997ec4f47b413a08fdd14 (diff)
downloadvoidsky-443dfb5c3e9438932bd61e754a01197604d03188.tar.zst
prevent deployment race conditions (#3416)
Diffstat (limited to '.github')
-rw-r--r--.github/workflows/bundle-deploy-eas-update.yml27
1 files changed, 22 insertions, 5 deletions
diff --git a/.github/workflows/bundle-deploy-eas-update.yml b/.github/workflows/bundle-deploy-eas-update.yml
index 6200db64a..65a633c8a 100644
--- a/.github/workflows/bundle-deploy-eas-update.yml
+++ b/.github/workflows/bundle-deploy-eas-update.yml
@@ -18,6 +18,10 @@ on:
         description: Runtime version (in x.x.x format) that this update is for
         required: true
 
+concurrency:
+    group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}
+    cancel-in-progress: true
+
 jobs:
   bundleDeploy:
     name: Bundle and Deploy EAS Update
@@ -44,7 +48,18 @@ jobs:
       - name: ⬇️ Checkout
         uses: actions/checkout@v4
         with:
-          fetch-depth: 100
+          fetch-depth: 0
+
+      - name: ⬇️ Get last successful deployment commit from the cache
+        id: get-base-commit
+        uses: actions/cache@v4
+        with:
+          path: last-successful-commit-hash.txt
+          key: last-successful-deployment-commit-${{ github.ref_name }}
+
+      - name: Add the last successful deployment commit to the output
+        id: last-successful-commit
+        run: echo base-commit=$(cat last-successful-commit-hash.txt) >> "$GITHUB_OUTPUT"
 
       - name: ⬇️ Fetch commits from base branch
         if: ${{ github.ref != 'refs/heads/main' }}
@@ -57,12 +72,12 @@ jobs:
           if [ -z "${{ inputs.channel == 'production' }}" ]; then
             echo base-commit=$(git show-ref -s ${{ inputs.runtimeVersion }}) >> "$GITHUB_OUTPUT"
           else
-            echo base-commit=$(git log -n 1 --skip 1 main --pretty=format:'%H') >> "$GITHUB_OUTPUT"
+            echo base-commit=${{ steps.last-successful-commit.base-commit }} >> "$GITHUB_OUTPUT"
           fi
 
       - name: ✓ Make sure we found a base commit
         run: |
-          if [ -z "${{ steps.base-commit.outputs.base-commit }}" ]; then
+          if [ -z "${{ steps.base-commit.outputs.base-commit }}" && ${{ inputs.channel == 'production' }} ]; then
             echo "Could not find a base commit for this release. Exiting."
             exit 1
           fi
@@ -82,7 +97,6 @@ jobs:
         uses: expo/expo-github-action/fingerprint@main
         with:
           previous-git-commit: ${{ steps.base-commit.outputs.base-commit }}
-          args:
 
       - name: 👀 Debug fingerprint
         id: fingerprint-debug
@@ -90,7 +104,8 @@ jobs:
           echo "previousGitCommit=${{ steps.fingerprint.outputs.previous-git-commit }} currentGitCommit=${{ steps.fingerprint.outputs.current-git-commit }}"
           echo "isPreviousFingerprintEmpty=${{ steps.fingerprint.outputs.previous-fingerprint == '' }}"
           
-          fingerprintDiff="${{ steps.fingerprint.outputs.fingerprint-diff }}"
+          fingerprintDiff='$(echo "${{ steps.fingerprint.outputs.fingerprint-diff }}")'
+          
           if [[ $fingerprintDiff =~ "bareRncliAutolinking" || $fingerprintDiff =~ "expoAutolinkingAndroid" || $fingerprintDiff =~ "expoAutolinkingIos" ]]; then
             echo fingerprint-is-different="true" >> "$GITHUB_OUTPUT"
           else
@@ -144,6 +159,8 @@ jobs:
           RUNTIME_VERSION: ${{ inputs.runtimeVersion }}
           CHANNEL_NAME: ${{ inputs.channel || 'testflight' }}
 
+      - name: Save successful deployment commit hash
+        run: echo ${{ steps.fingerprint.outputs.current-git-commit }} > last-successful-commit-hash.txt
 
   # GitHub actions are horrible so let's just copy paste this in
   buildIfNecessaryIOS: