1--- 2title: Using GitHub Actions 3--- 4 5A GitHub Action is a cloud function that runs every time an event on GitHub occurs. We can use GitHub Actions to automate building and publishing updates when you or members on your team merge to a branch, like "production". This makes the process of deploying consistent and fast, leaving you more time to develop your app. 6 7## Publish updates on push 8 9We can configure GitHub Actions to run on any GitHub event. One of the most common use cases is to publish an update when code is pushed. Below are the steps to publish an update every time an update is pushed: 10 111. Create a file path named `.github/workflows/update.yml` at the root of your project. 122. Inside `update.yml`, copy and paste this code: 13 14 ```yaml 15 name: update 16 on: push 17 18 jobs: 19 update: 20 name: EAS Update 21 runs-on: ubuntu-latest 22 steps: 23 - name: Check for EXPO_TOKEN 24 run: | 25 if [ -z "${{ secrets.EXPO_TOKEN }}" ]; then 26 echo "You must provide an EXPO_TOKEN secret linked to this project's Expo account in this repo's secrets. Learn more: https://docs.expo.dev/eas-update/github-actions" 27 exit 1 28 fi 29 30 - name: Checkout repository 31 uses: actions/checkout@v2 32 33 - name: Setup Node 34 uses: actions/setup-node@v2 35 with: 36 node-version: 16.x 37 cache: yarn 38 39 - name: Setup Expo 40 uses: expo/expo-github-action@v7 41 with: 42 expo-version: latest 43 eas-version: latest 44 token: ${{ secrets.EXPO_TOKEN }} 45 46 - name: Find yarn cache 47 id: yarn-cache-path 48 run: echo "::set-output name=dir::$(yarn cache dir)" 49 50 - name: Restore cache 51 uses: actions/cache@v2 52 with: 53 path: ${{ steps.yarn-cache-path.outputs.dir }} 54 key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} 55 restore-keys: ${{ runner.os }}-yarn- 56 57 - name: Install dependencies 58 run: yarn install --immutable 59 60 - name: Publish update 61 run: eas update --auto 62 ``` 63 64 In the code above, we set the action to run every time code is pushed to any branch. In the `update` job, we set up Node, in addition to Expo's GitHub Action: `expo-github-action`. We then add a couple steps to cache any dependencies installed from the last run to speed this script up on subsequent runs. At the end, we install dependencies (`yarn install`), then publish the update with `eas update --auto`. Since we're using the `--auto` flag, the EAS branch will be named after the GitHub branch, and the message for the update will match the commit's message. 65 663. Finally, we need to give the script above permission to run by providing an `EXPO_TOKEN` environment variable. 67 1. Navigate to [https://expo.dev/settings/access-tokens](https://expo.dev/settings/access-tokens). 68 2. Click "Create" to create a new access token. 69 3. Copy the token generated. 70 4. Navigate to https://github.com/your-username/your-repo-name/settings/secrets/actions, replacing "your-username" and "your-repo-name" with your project's info. 71 5. Click "New repository secret" 72 6. Make the secret's name "EXPO_TOKEN", then paste the access token in as the value. 73 74Your GitHub Action should be set up now. Every time when a developer merges code into the repo, this action will build an update and publish it, making it available to all of our devices with builds that have access to the EAS branch. 75 76> Some repositories or organizations might need to explicitly enable GitHub Workflows and allow third-party Actions. 77