1--- 2title: Using GitHub Actions 3description: Learn how to use GitHub Actions to automate publishing updates with EAS Update. 4hideTOC: true 5--- 6 7import { Step } from '~/ui/components/Step'; 8 9A 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 of 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. 10 11## Publish updates on push 12 13We 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: 14 15<Step label="1"> 16 17Create a file path named **.github/workflows/update.yml** at the root of your project. 18 19</Step> 20 21<Step label="2"> 22 23Inside **update.yml**, copy and paste the following snippet: 24 25```yaml 26name: update 27on: push 28 29jobs: 30 update: 31 name: EAS Update 32 runs-on: ubuntu-latest 33 steps: 34 - name: Check for EXPO_TOKEN 35 run: | 36 if [ -z "${{ secrets.EXPO_TOKEN }}" ]; then 37 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" 38 exit 1 39 fi 40 41 - name: Checkout repository 42 uses: actions/checkout@v2 43 44 - name: Setup Node 45 uses: actions/setup-node@v2 46 with: 47 node-version: 16.x 48 cache: yarn 49 50 - name: Setup Expo 51 uses: expo/expo-github-action@v7 52 with: 53 expo-version: latest 54 eas-version: latest 55 token: ${{ secrets.EXPO_TOKEN }} 56 57 - name: Find yarn cache 58 id: yarn-cache-path 59 run: echo "::set-output name=dir::$(yarn cache dir)" 60 61 - name: Restore cache 62 uses: actions/cache@v2 63 with: 64 path: ${{ steps.yarn-cache-path.outputs.dir }} 65 key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} 66 restore-keys: ${{ runner.os }}-yarn- 67 68 - name: Install dependencies 69 run: yarn install --immutable 70 71 - name: Publish update 72 run: eas update --auto 73``` 74 75In 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 of steps to cache any dependencies installed from the last run to speed this script up on subsequent runs. In 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. 76 77</Step> 78 79<Step label="3"> 80 81Finally, we need to give the script above permission to run by providing an `EXPO_TOKEN` environment variable. 82 831. Navigate to [https://expo.dev/settings/access-tokens](https://expo.dev/settings/access-tokens). 842. Click "Create" to create a new access token. 853. Copy the token generated. 864. 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. 875. Click "New repository secret" 886. Make the secret's name "EXPO_TOKEN", then paste the access token in as the value. 89 90Your GitHub Action should be set up now. Whenever 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. 91 92> Some repositories or organizations might need to explicitly enable GitHub Workflows and allow third-party Actions. 93 94</Step> 95