use custom github action for fingerprinting (#4226)

* use custom github action for fingerprinting

* update pr workflow

* update names of workflows

* make a native change (testing)

* adjust the action

* Revert "make a native change (testing)"

This reverts commit 8db98357330c24b4ac89b795dc73e3d84a29d9af.

* update bundle-deploy script

* test a prod build

* crazy depth

* manually set

* use prod default

* force prod

* revert test changes

* save cache after deploy

* revert testing
zio/stable
Hailey 2024-05-28 16:38:24 -07:00 committed by GitHub
parent adbbded003
commit 5ceb440d4e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 84 additions and 87 deletions

View File

@ -119,3 +119,15 @@ jobs:
env: env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_CLIENT_ALERT_WEBHOOK }} SLACK_WEBHOOK_URL: ${{ secrets.SLACK_CLIENT_ALERT_WEBHOOK }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
- name: ⬇️ Restore Cache
id: get-base-commit
uses: actions/cache@v4
if: ${{ inputs.profile == 'testflight' && github.ref == 'refs/heads/main' }}
with:
path: most-recent-testflight-commit.txt
key: most-recent-testflight-commit
- name: ✏️ Write commit hash to cache
if: ${{ inputs.profile == 'testflight' && github.ref == 'refs/heads/main' }}
run: echo ${{ github.sha }} > most-recent-testflight-commit.txt

View File

@ -76,3 +76,15 @@ jobs:
- name: 🚀 Deploy - name: 🚀 Deploy
run: eas submit -p ios --non-interactive --path build.ipa run: eas submit -p ios --non-interactive --path build.ipa
- name: ⬇️ Restore Cache
id: get-base-commit
uses: actions/cache@v4
if: ${{ inputs.profile == 'testflight' && github.ref == 'refs/heads/main' }}
with:
path: most-recent-testflight-commit.txt
key: most-recent-testflight-commit
- name: ✏️ Write commit hash to cache
if: ${{ inputs.profile == 'testflight' && github.ref == 'refs/heads/main' }}
run: echo ${{ github.sha }} > most-recent-testflight-commit.txt

View File

@ -26,7 +26,7 @@ jobs:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}-deploy group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}-deploy
cancel-in-progress: true cancel-in-progress: true
outputs: outputs:
fingerprint-is-different: ${{ steps.fingerprint-debug.outputs.fingerprint-is-different }} changes-detected: ${{ steps.fingerprint.outputs.includes-changes }}
steps: steps:
- name: Check for EXPO_TOKEN - name: Check for EXPO_TOKEN
@ -49,69 +49,22 @@ jobs:
with: with:
fetch-depth: 0 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 }}-${{ github.sha }}
restore-keys: |
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 - name: ⬇️ Fetch commits from base branch
if: ${{ github.ref != 'refs/heads/main' }} if: ${{ github.ref != 'refs/heads/main' }}
run: git fetch origin main:main --depth 100 run: git fetch origin main:main --depth 100
# This should get the current production release's commit's hash to see if the update is compatible
- name: 🕵️ Get the base commit
id: base-commit
run: |
if ${{ inputs.channel == 'production' }}; then
echo base-commit=$(git show-ref -s ${{ inputs.runtimeVersion }}) >> "$GITHUB_OUTPUT"
else
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 }}" && ${{ inputs.channel == 'production' }} ]; then
echo "Could not find a base commit for this release. Exiting."
exit 1
fi
- name: 🔧 Setup Node - name: 🔧 Setup Node
uses: actions/setup-node@v4 uses: actions/setup-node@v4
with: with:
node-version-file: .nvmrc node-version-file: .nvmrc
cache: yarn cache: yarn
- name: ⚙️ Install Dependencies - name: 📷 Check fingerprint and install dependencies
run: yarn install
# Run the fingerprint
- name: 📷 Check fingerprint
id: fingerprint id: fingerprint
uses: expo/expo-github-action/fingerprint@main uses: bluesky-social/github-actions/fingerprint-native@main
with: with:
previous-git-commit: ${{ steps.base-commit.outputs.base-commit }} profile: ${{ inputs.channel || 'testflight' }}
previous-commit-tag: ${{ inputs.runtimeVersion }}
- name: 👀 Debug fingerprint
id: fingerprint-debug
run: |
echo "previousGitCommit=${{ steps.fingerprint.outputs.previous-git-commit }} currentGitCommit=${{ steps.fingerprint.outputs.current-git-commit }}"
echo "isPreviousFingerprintEmpty=${{ steps.fingerprint.outputs.previous-fingerprint == '' }}"
fingerprintDiff='$(echo "${{ steps.fingerprint.outputs.fingerprint-diff }}")'
if [[ $fingerprintDiff =~ "bareRncliAutolinking" || $fingerprintDiff =~ "expoAutolinkingAndroid" || $fingerprintDiff =~ "expoAutolinkingIos" ]]; then
echo fingerprint-is-different="true" >> "$GITHUB_OUTPUT"
else
echo fingerprint-is-different="false" >> "$GITHUB_OUTPUT"
fi
- name: Lint check - name: Lint check
run: yarn lint run: yarn lint
@ -127,22 +80,22 @@ jobs:
- name: 🔨 Setup EAS - name: 🔨 Setup EAS
uses: expo/expo-github-action@v8 uses: expo/expo-github-action@v8
if: ${{ steps.fingerprint-debug.outputs.fingerprint-is-different == 'false'}} if: ${{ !steps.fingerprint.outputs.includes-changes }}
with: with:
expo-version: latest expo-version: latest
eas-version: latest eas-version: latest
token: ${{ secrets.EXPO_TOKEN }} token: ${{ secrets.EXPO_TOKEN }}
- name: ⛏️ Setup Expo - name: ⛏️ Setup Expo
if: ${{ steps.fingerprint-debug.outputs.fingerprint-is-different == 'false'}} if: ${{ !steps.fingerprint.outputs.includes-changes }}
run: yarn global add eas-cli-local-build-plugin run: yarn global add eas-cli-local-build-plugin
- name: 🪛 Setup jq - name: 🪛 Setup jq
if: ${{ steps.fingerprint-debug.outputs.fingerprint-is-different == 'false'}} if: ${{ !steps.fingerprint.outputs.includes-changes }}
uses: dcarbone/install-jq-action@v2 uses: dcarbone/install-jq-action@v2
- name: ✏️ Write environment variables - name: ✏️ Write environment variables
if: ${{ steps.fingerprint-debug.outputs.fingerprint-is-different == 'false'}} if: ${{ !steps.fingerprint.outputs.includes-changes }}
run: | run: |
export json='${{ secrets.GOOGLE_SERVICES_TOKEN }}' export json='${{ secrets.GOOGLE_SERVICES_TOKEN }}'
echo "${{ secrets.ENV_TOKEN }}" > .env echo "${{ secrets.ENV_TOKEN }}" > .env
@ -151,19 +104,28 @@ jobs:
echo "$json" > google-services.json echo "$json" > google-services.json
- name: 🏗️ Create Bundle - name: 🏗️ Create Bundle
if: ${{ steps.fingerprint-debug.outputs.fingerprint-is-different == 'false'}} if: ${{ !steps.fingerprint.outputs.includes-changes }}
run: EXPO_PUBLIC_ENV="${{ inputs.channel || 'testflight' }}" yarn export run: EXPO_PUBLIC_ENV="${{ inputs.channel || 'testflight' }}" yarn export
- name: 📦 Package Bundle and 🚀 Deploy - name: 📦 Package Bundle and 🚀 Deploy
if: ${{ steps.fingerprint-debug.outputs.fingerprint-is-different == 'false'}} if: ${{ !steps.fingerprint.outputs.includes-changes }}
run: yarn use-build-number bash scripts/bundleUpdate.sh run: yarn use-build-number bash scripts/bundleUpdate.sh
env: env:
DENIS_API_KEY: ${{ secrets.DENIS_API_KEY }} DENIS_API_KEY: ${{ secrets.DENIS_API_KEY }}
RUNTIME_VERSION: ${{ inputs.runtimeVersion }} RUNTIME_VERSION: ${{ inputs.runtimeVersion }}
CHANNEL_NAME: ${{ inputs.channel || 'testflight' }} CHANNEL_NAME: ${{ inputs.channel || 'testflight' }}
- name: Save successful deployment commit hash - name: ⬇️ Restore Cache
run: echo ${{ steps.fingerprint.outputs.current-git-commit }} > last-successful-commit-hash.txt id: get-base-commit
uses: actions/cache@v4
if: ${{ !steps.fingerprint.outputs.includes-changes }}
with:
path: most-recent-testflight-commit.txt
key: most-recent-testflight-commit
- name: ✏️ Write commit hash to cache
if: ${{ !steps.fingerprint.outputs.includes-changes }}
run: echo ${{ github.sha }} > most-recent-testflight-commit.txt
# GitHub actions are horrible so let's just copy paste this in # GitHub actions are horrible so let's just copy paste this in
buildIfNecessaryIOS: buildIfNecessaryIOS:
@ -171,11 +133,11 @@ jobs:
runs-on: macos-14 runs-on: macos-14
concurrency: concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}-build-ios group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}-build-ios
cancel-in-progress: false cancel-in-progress: true
needs: [bundleDeploy] needs: [bundleDeploy]
# Gotta check if its NOT '[]' because any md5 hash in the outputs is detected as a possible secret and won't be # Gotta check if its NOT '[]' because any md5 hash in the outputs is detected as a possible secret and won't be
# available here # available here
if: ${{ inputs.channel != 'production' && needs.bundleDeploy.outputs.fingerprint-is-different == 'true' }} if: ${{ inputs.channel != 'production' && needs.bundleDeploy.outputs.changes-detected }}
steps: steps:
- name: Check for EXPO_TOKEN - name: Check for EXPO_TOKEN
run: > run: >
@ -238,6 +200,18 @@ jobs:
- name: 🚀 Deploy - name: 🚀 Deploy
run: eas submit -p ios --non-interactive --path build.ipa run: eas submit -p ios --non-interactive --path build.ipa
- name: ⬇️ Restore Cache
id: get-base-commit
uses: actions/cache@v4
if: ${{ inputs.channel == 'testflight' }}
with:
path: most-recent-testflight-commit.txt
key: most-recent-testflight-commit
- name: ✏️ Write commit hash to cache
if: ${{ inputs.channel == 'testflight' }}
run: echo ${{ github.sha }} > most-recent-testflight-commit.txt
buildIfNecessaryAndroid: buildIfNecessaryAndroid:
name: Build and Submit Android name: Build and Submit Android
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -247,7 +221,7 @@ jobs:
needs: [ bundleDeploy ] needs: [ bundleDeploy ]
# Gotta check if its NOT '[]' because any md5 hash in the outputs is detected as a possible secret and won't be # Gotta check if its NOT '[]' because any md5 hash in the outputs is detected as a possible secret and won't be
# available here # available here
if: ${{ inputs.channel != 'production' && needs.bundleDeploy.outputs.fingerprint-is-different == 'true' }} if: ${{ inputs.channel != 'production' && needs.bundleDeploy.outputs.changes-detected }}
steps: steps:
- name: Check for EXPO_TOKEN - name: Check for EXPO_TOKEN
@ -325,3 +299,15 @@ jobs:
env: env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_CLIENT_ALERT_WEBHOOK }} SLACK_WEBHOOK_URL: ${{ secrets.SLACK_CLIENT_ALERT_WEBHOOK }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
- name: ⬇️ Restore Cache
id: get-base-commit
uses: actions/cache@v4
if: ${{ inputs.channel == 'testflight' }}
with:
path: most-recent-testflight-commit.txt
key: most-recent-testflight-commit
- name: ✏️ Write commit hash to cache
if: ${{ inputs.channel == 'testflight' }}
run: echo ${{ github.sha }} > most-recent-testflight-commit.txt

View File

@ -1,7 +1,7 @@
# Credit for fingerprint action https://github.com/expo/expo # Credit for fingerprint action https://github.com/expo/expo
# https://github.com/expo/expo/blob/main/.github/workflows/pr-labeler.yml # https://github.com/expo/expo/blob/main/.github/workflows/pr-labeler.yml
--- ---
name: PR labeler name: PR Tests
on: on:
push: push:
@ -21,7 +21,7 @@ permissions:
jobs: jobs:
webpack-analyzer: webpack-analyzer:
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04
if: ${{ github.event.pull_request.head.repo.full_name == github.repository }} if: ${{ github.event.pull_request.head.repo.full_name == github.repository && github.event_name == 'pull_request'}}
steps: steps:
- name: ⬇️ Checkout - name: ⬇️ Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
@ -94,10 +94,9 @@ jobs:
| ${{ steps.get-diff.outputs.base_file_string }} | ${{ steps.get-diff.outputs.pr_file_string }} | ${{ steps.get-diff.outputs.diff_file_string }} (${{ steps.get-diff.outputs.percent }}%) | | ${{ steps.get-diff.outputs.base_file_string }} | ${{ steps.get-diff.outputs.pr_file_string }} | ${{ steps.get-diff.outputs.diff_file_string }} (${{ steps.get-diff.outputs.percent }}%) |
--- ---
test-suite-fingerprint: fingerprint-native:
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04
if: ${{ github.event.pull_request.head.repo.full_name == github.repository || github.event_name == 'push' }} if: ${{ github.event.pull_request.head.repo.full_name == github.repository && github.event_name == 'pull_request'}}
concurrency: fingerprint-${{ github.event_name != 'pull_request' && 'main' || github.run_id }}
steps: steps:
- name: ⬇️ Checkout - name: ⬇️ Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
@ -114,35 +113,23 @@ jobs:
node-version-file: .nvmrc node-version-file: .nvmrc
cache: yarn cache: yarn
- name: ⚙️ Install Dependencies - name: 📷 Check fingerprint and install dependencies
run: yarn install
- name: Get the base commit
id: base-commit
run: echo base-commit=$(git log -n 1 main --pretty=format:'%H') >> "$GITHUB_OUTPUT"
- name: 📷 Check fingerprint
id: fingerprint id: fingerprint
uses: expo/expo-github-action/fingerprint@main uses: bluesky-social/github-actions/fingerprint-native@main
with: with:
previous-git-commit: ${{ steps.base-commit.outputs.base-commit }} profile: pull-request
- name: 👀 Debug fingerprint
run: |
echo "previousGitCommit=${{ steps.fingerprint.outputs.previous-git-commit }} currentGitCommit=${{ steps.fingerprint.outputs.current-git-commit }}"
echo "isPreviousFingerprintEmpty=${{ steps.fingerprint.outputs.previous-fingerprint == '' }}"
- name: 💬 Drop a comment - name: 💬 Drop a comment
uses: marocchino/sticky-pull-request-comment@v2 uses: marocchino/sticky-pull-request-comment@v2
if: ${{ github.event_name == 'pull_request' && steps.fingerprint.outputs.fingerprint-diff != '[]' }} if: ${{ steps.fingerprint.outputs.includes-changes }}
with: with:
header: fingerprint-diff header: fingerprint-diff
message: | message: |
The Pull Request introduced fingerprint changes against the base commit: ${{ steps.fingerprint.outputs.previous-git-commit }} The Pull Request introduced fingerprint changes against the base commit:
<details><summary>Fingerprint diff</summary> <details><summary>Fingerprint diff</summary>
```json ```json
${{ steps.fingerprint.outputs.fingerprint-diff }} ${{ steps.fingerprint.outputs.diff }}
``` ```
</details> </details>
@ -152,7 +139,7 @@ jobs:
- name: 💬 Delete comment - name: 💬 Delete comment
uses: marocchino/sticky-pull-request-comment@v2 uses: marocchino/sticky-pull-request-comment@v2
if: ${{ github.event_name == 'pull_request' && steps.fingerprint.outputs.fingerprint-diff == '[]' }} if: ${{ !steps.fingerprint.outputs.includes-changes }}
with: with:
header: fingerprint-diff header: fingerprint-diff
delete: true delete: true