Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature(preview): add eas update preview sub-action #206

Merged
merged 12 commits into from
Feb 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 101 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,107 @@ jobs:
if: ${{ env.hasAuth == 'true' }}
run: expo whoami

preview:
runs-on: ubuntu-latest
steps:
- name: 🏗 Setup repo
uses: actions/checkout@v3

- name: 🏗 Setup Node
uses: actions/setup-node@v3
with:
node-version: 18.x
cache: yarn

- name: 🏗 Setup EAS
uses: ./
with:
eas-version: latest
token: ${{ secrets.EXPO_TOKEN }}

- name: 🏗 Setup project
run: yarn create expo-app ./temp

- name: 👷 Configure project
working-directory: ./temp
run: |
eas init --id ${{ secrets.EXPO_PROJECT_ID }} --force --non-interactive
echo $(jq '.expo.runtimeVersion.policy = "sdkVersion"' app.json) > app.json

- name: 🚀 Create preview (without comment)
if: ${{ env.hasAuth == 'true' }}
uses: ./preview
id: no-comment
env:
EXPO_TEST_GITHUB_PULL: 206
with:
working-directory: ./temp
command: eas update --branch test --message "This is a test"
comment: false

- name: 🧪 Comment has content
if: ${{ env.hasAuth == 'true' }}
uses: actions/github-script@v6
with:
script: |
const comment = `${{ steps.no-comment.outputs.comment }}`
if (!comment) {
console.log({ comment });
throw new Error('Message output is empty');
}

- name: 🚀 Create preview (single QR)
if: ${{ env.hasAuth == 'true' }}
id: single-qr
uses: ./preview
env:
EXPO_TEST_GITHUB_PULL: 206
with:
working-directory: ./temp
command: eas update --branch test --message "This is a test"
comment-id: 'projectId:{projectId} single-qr'

- name: 🧪 Single QR has content
if: ${{ env.hasAuth == 'true' }}
uses: actions/github-script@v6
with:
script: |
const comment = `${{ steps.single-qr.outputs.comment }}`
if (!comment) {
console.log({ comment });
throw new Error('Message output is empty');
}

- name: 👷 Configure runtime versions
working-directory: ./temp
run: |
echo $(jq 'del(.expo.runtimeVersion)' app.json) > app.json
echo $(jq '.expo.android.runtimeVersion.policy = "sdkVersion"' app.json) > app.json
echo $(jq '.expo.ios.runtimeVersion.policy = "appVersion"' app.json) > app.json
echo $(jq '.expo.scheme = "expogithubaction"' app.json) > app.json

- name: 🚀 Create preview (multi QR)
if: ${{ env.hasAuth == 'true' }}
id: multi-qr
uses: ./preview
env:
EXPO_TEST_GITHUB_PULL: 206
with:
working-directory: ./temp
command: eas update --branch test --message "This is a test"
comment-id: 'projectId:{projectId} multi-qr'

- name: 🧪 Multi QR has content
if: ${{ env.hasAuth == 'true' }}
uses: actions/github-script@v6
with:
script: |
const comment = `${{ steps.multi-qr.outputs.comment }}`
if (!comment) {
console.log({ comment });
throw new Error('Message output is empty');
}

preview-comment:
runs-on: ubuntu-latest
steps:
Expand Down
9 changes: 9 additions & 0 deletions build/command/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20651,6 +20651,15 @@ function pullContext() {
assert(context.eventName === 'pull_request', 'Could not find the pull request context, make sure to run this from a pull_request triggered workflow');
return context.issue;
}
function hasPullContext() {
try {
pullContext();
return true;
}
catch {
return false;
}
}
async function createReaction(options) {
const github = githubApi(options);
if (options.comment_id) {
Expand Down
9 changes: 9 additions & 0 deletions build/preview-comment/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20652,6 +20652,15 @@ function pullContext() {
(0,external_assert_.ok)(github.context.eventName === 'pull_request', 'Could not find the pull request context, make sure to run this from a pull_request triggered workflow');
return github.context.issue;
}
function hasPullContext() {
try {
pullContext();
return true;
}
catch {
return false;
}
}
async function createReaction(options) {
const github = githubApi(options);
if (options.comment_id) {
Expand Down
Loading