I am in the process of automating my react-native
Expo release-cycle. I am using release channels
in Expo to build staging
and production
builds. For example, on every push to staging-v1
GitHub branch, the action below is triggered.
//staging.yaml
name: Release to staging
on:
push:
branches:
- staging*
jobs:
publish:
name: Install and publish on staging channel
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: 12.x
- uses: expo/expo-github-action@v5
with:
expo-version: 3.x
expo-username: ${{ secrets.EXPO_CLI_USERNAME }}
expo-password: ${{ secrets.EXPO_CLI_PASSWORD }}
expo-packager: npm
- run: npm install
- run: expo publish --release-channel ${{ GITHUB_REF }}
{{ GITHUB_REF }}
holds the current branch name. So when I push my changes to staging-v1
this action runs. However, I am getting this error.
I've tried setting env
variables, it did not work also. I just want to append my branch_name
to the expo publish
command. Ultimately, when building, the run
command should look like this.
- run: npm install
- run: expo publish --release-channel staging-v1
Any insight into this problem will be greatly appreciated. Thanks :)
I built a GitHub Action for this: FranzDiebold/github-env-vars-action
The usage is as follows:
steps:
- uses: FranzDiebold/[email protected]
- name: Print environment variables
run: |
echo "GITHUB_REPOSITORY_SLUG=$GITHUB_REPOSITORY_SLUG"
echo "GITHUB_REPOSITORY_OWNER=$GITHUB_REPOSITORY_OWNER"
echo "GITHUB_REPOSITORY_OWNER_SLUG=$GITHUB_REPOSITORY_OWNER_SLUG"
echo "GITHUB_REPOSITORY_NAME=$GITHUB_REPOSITORY_NAME"
echo "GITHUB_REPOSITORY_NAME_SLUG=$GITHUB_REPOSITORY_NAME_SLUG"
echo "GITHUB_REF_SLUG=$GITHUB_REF_SLUG"
echo "GITHUB_REF_NAME=$GITHUB_REF_NAME"
echo "GITHUB_REF_NAME_SLUG=$GITHUB_REF_NAME_SLUG"
echo "GITHUB_SHA_SHORT=$GITHUB_SHA_SHORT"
An example output is:
GITHUB_REPOSITORY_SLUG=ajinkabeer-test-repo
GITHUB_REPOSITORY_OWNER=ajinkabeer
GITHUB_REPOSITORY_OWNER_SLUG=ajinkabeer
GITHUB_REPOSITORY_NAME=test-repo
GITHUB_REPOSITORY_NAME_SLUG=test-repo
GITHUB_REF_SLUG=refs-heads-staging-v1
GITHUB_REF_NAME=staging-v1
GITHUB_REF_NAME_SLUG=staging-v1
GITHUB_SHA_SHORT=e2e4f0ab
A demo for all Operating systems (Linux, macOS and Windows) is also available in the demo workflows file of the repository!
After a lot of trial and error, I've found the solution. I used the github-slug-action workflow to access my branch_name
.
name: Release to staging
on:
push:
branches:
- staging*
jobs:
publish:
name: Install and publish on staging channel
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: 12.x
- uses: expo/expo-github-action@v5
with:
expo-version: 3.x
expo-username: ${{ secrets.EXPO_CLI_USERNAME }}
expo-password: ${{ secrets.EXPO_CLI_PASSWORD }}
expo-packager: npm
- run: npm install
- name: Run tests
run: |
npm test
- uses: rlespinasse/[email protected]
- run: expo publish --release-channel=${{ env.GITHUB_REF_SLUG }}
Here is the log.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With