expo-github-action

repository·main·Indexed 21 days ago

https://github.com/expo/expo-github-action

A GitHub Action that automates Expo and EAS CLI workflows. It allows developers to publish updates, trigger builds, and manage previews automatically. Key features include the 'command' sub-action for triggering EAS builds via PR comments, and 'continuous-deploy-fingerprint' for automating deployments based on the expo-updates fingerprint runtime version policy.

Tokens
18.6K
Snippets
38
Records
64
Agent score
73%

What's inside expo-github-action

  1. Overview of continuous-deploy-fingerprint

    main

    continuous-deploy-fingerprint is a GitHub Action designed for continuous deployment of Expo projects using the expo-updates fingerprint runtime version policy.

    When executed, the action performs the following steps for each platform (iOS and Android):

    1. Fingerprint Check: Determines the current fingerprint of the project.
    2. Build Verification: Checks for existing EAS builds (in-progress or finished) that match the current fingerprint and the specified profile.
    3. Conditional Build: If no matching build is found, it starts a new EAS build. It can optionally submit these builds to app stores.
    4. Update Publication: Publishes an update to EAS Update.
    5. PR Feedback: If running on a Pull Request, it posts a comment summarizing the actions taken.
  2. Overview of the fingerprint GitHub Action

    main
    The fingerprint action uses @expo/fingerprint to check project fingerprinting for pull requests. It determines if a pull request is 'fingerprint compatible' (meaning no native code changes were made, making it compatible with Over-The-Air updates) or if the fingerprint has changed (indicating native code changes). This allows developers to reuse existing builds instead of creating new ones when the fingerprint remains the same.
  3. Use the preview-comment action to add QR codes to pull requests

    main

    The expo/expo-github-action/preview-comment subaction allows you to automatically comment on pull requests with Expo QR codes. This enables reviewers to load the app directly on their mobile devices.

    Note: This action only creates the comment; it does not publish your project. You must run a publishing command (like expo publish) in a previous step.

          - name: 💬 Comment in preview
            uses: expo/expo-github-action/preview-comment@v8
            with:
              channel: pr-${{ github.event.number }}
  4. How automatic Expo login works

    main

    The action exports the provided token to the environment to ensure you are authenticated for subsequent steps (like expo publish or eas build).

    Important: The token is not stored by the action. Each separate workflow job must set up the token individually using the token input.

  5. How GitHub token authentication works in expo-github-action/command

    main

    The action requires authentication to interact with the GitHub API (e.g., to post comments).

    • Automatic Authentication: The action attempts to use the automatic token authentication provided by GitHub Actions by default.
    • Manual Overrides: You can explicitly provide a token in two ways:
      1. Set the github-token input in the action configuration.
      2. Set the GITHUB_TOKEN environment variable.
  6. How preview-build works with fingerprinting

    main

    The preview-build action uses @expo/fingerprint to determine if a pull request requires a new EAS Build.

    • Fingerprint Compatible: If the fingerprint remains the same, it means no native code has changed, and the PR is compatible with existing EAS Updates. No new build is created.
    • Fingerprint Changed: If the fingerprint changes, it indicates native code changes. The action will then execute the specified EAS Build command to create a new build.

    This mechanism allows you to reuse existing builds and avoid unnecessary build costs and time when only JavaScript/assets change.

  7. Prevent duplicate preview comments

    main
    To avoid spamming pull requests with new comments on every update, the action uses a message-id. Every comment contains a generated message-id that identifies the previous comment. If the action detects an existing comment with the same ID, it will update the existing comment instead of creating a new one.
  8. How the built-in cache works

    main

    The action uses @actions/cache to restore previous installations of Expo and EAS CLI. This reduces installation time by downloading and extracting a single tar file instead of performing a fresh install.

    Note: Using the cache counts towards your GitHub repository's cache limit. Expo and EAS CLI are stored in separate caches.

  9. Configure GitHub authentication for preview comments

    main
    The action requires authentication to post comments via the GitHub API. It attempts to use the automatic GITHUB_TOKEN provided by GitHub Actions. If you need to use a different token, you can provide it via the github-token input or the GITHUB_TOKEN environment variable.