Skip to content

Add manual trigger to build apps #6

Add manual trigger to build apps

Add manual trigger to build apps #6

Workflow file for this run

---
name: build-fork-pr
on:
workflow_dispatch:
inputs:
branch:
description: 'Branch to build'
required: true
default: 'main'
platform:
description: 'Platform to build'
required: true
type: choice
default: 'android'
options:
- ios
- android
pull_request:
types:
- labeled
# Limit permissions of the GITHUB_TOKEN
permissions:
contents: read
pull-requests: write
env:
NODE_VERSION: 22.14.0
TERM: xterm
IS_FORK: ${{ github.event.pull_request.head.repo.fork == true }}
jobs:
test:
runs-on: ubuntu-22.04
if: ${{ (github.event.label.name == 'Build Apps for PR' || github.event.label.name == 'Build App for iOS' || github.event.label.name == 'Build App for Android' || (github.event_name == 'workflow_dispatch' && (github.event.inputs.platform == 'ios' || github.event.inputs.platform == 'android'))) && github.event.pull_request.head.repo.fork == true }}
steps:
- name: ci/checkout-repo
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: ci/test
uses: ./.github/actions/test
build-ios-fork-pr:
runs-on: macos-14-large
if: ${{ (github.event.label.name == 'Build Apps for PR' || github.event.label.name == 'Build App for iOS' || (github.event_name == 'workflow_dispatch' && github.event.inputs.platform == 'ios')) && github.event.pull_request.head.repo.fork == true }}
needs:
- test
steps:
- name: ci/checkout-repo
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: ci/prepare-ios-build
uses: ./.github/actions/prepare-ios-build
- name: ci/setup-fork-ios-build
run: |
echo "Using debug code signing for fork build"
echo "CODE_SIGN_IDENTITY=" >> $GITHUB_ENV
echo "CODE_SIGNING_REQUIRED=NO" >> $GITHUB_ENV
- name: ci/build-ios-fork-pr
env:
BRANCH_TO_BUILD: "${{ github.event.pull_request.head.ref || github.event.inputs.branch }}"
GITHUB_PR_NUMBER: "${{ github.event.pull_request.number }}"
GITHUB_EVENT_NAME: "${{ github.event_name }}"
AWS_ACCESS_KEY_ID: "${{ secrets.FORK_AWS_ACCESS_KEY_ID }}"
AWS_SECRET_ACCESS_KEY: "${{ secrets.FORK_AWS_SECRET_ACCESS_KEY }}"
MATTERMOST_WEBHOOK_URL: "${{ secrets.FORK_MATTERMOST_WEBHOOK_URL }}"
AWS_BUCKET_NAME: "${{ secrets.FORK_AWS_BUCKET_NAME }}"
AWS_REGION: "${{ secrets.FORK_AWS_REGION }}"
AWS_FOLDER_NAME: "mattermost-mobile"
BUILD_PR: "true"
IOS_BUILD_EXPORT_METHOD: "development"
SENTRY_ENABLED: "false"
run: |
bundle exec fastlane ios build --env ios.pr
working-directory: ./fastlane
- name: ci/upload-ios-fork-pr-build
id: ci-upload-ios-fork-pr-build
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: ios-fork-build-pr-${{ github.run_id }}
path: "*.ipa"
- name: ci/post-artifact-link-to-pr
if: github.event_name == 'pull_request'
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const prNumber = '${{ github.event.pull_request.number }}';
const installUrl = `itms-services://?action=download-manifest&url=https://pr-builds.mattermost.com/mattermost-mobile/${prNumber}/merge/Mattermost_Beta.plist`;
const message = `### iOS PR Build\n\nYou can install the iOS app directly from:\n- [Install from PR Builds](${installUrl})\n\nCommit: ${{ github.event.pull_request.head.sha }}`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: message
});
build-android-fork-pr:
runs-on: ubuntu-22.04
if: ${{ (github.event.label.name == 'Build Apps for PR' || github.event.label.name == 'Build App for Android' || (github.event_name == 'workflow_dispatch' && github.event.inputs.platform == 'android')) && github.event.pull_request.head.repo.fork == true }}
needs:
- test
steps:
- name: ci/checkout-repo
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: ci/prepare-android-build
uses: ./.github/actions/prepare-android-build
- name: ci/setup-fork-android-build
run: |
# Generate debug keystore if missing
debug_keystore_path="android/app/debug.keystore"
if [ ! -f "$debug_keystore_path" ]; then
mkdir -p android/app
keytool -genkey -v -keystore $debug_keystore_path \
-alias androiddebugkey -storepass android -keypass android \
-keyalg RSA -keysize 2048 -validity 10000 -dname "CN=, OU=, O=, L=, S=, C="
fi
- name: ci/build-android-fork-pr
env:
BRANCH_TO_BUILD: "${{ github.event.pull_request.head.ref || github.event.inputs.branch }}"
GITHUB_PR_NUMBER: "${{ github.event.pull_request.number }}"
GITHUB_EVENT_NAME: "${{ github.event_name }}"
AWS_ACCESS_KEY_ID: "${{ secrets.FORK_AWS_ACCESS_KEY_ID }}"
AWS_SECRET_ACCESS_KEY: "${{ secrets.FORK_AWS_SECRET_ACCESS_KEY }}"
MATTERMOST_WEBHOOK_URL: "${{ secrets.FORK_MATTERMOST_WEBHOOK_URL }}"
AWS_BUCKET_NAME: "${{ secrets.FORK_AWS_BUCKET_NAME }}"
AWS_REGION: "${{ secrets.FORK_AWS_REGION }}"
AWS_FOLDER_NAME: "mattermost-mobile"
BUILD_PR: "true"
SENTRY_ENABLED: "false"
run: bundle exec fastlane android build --env android.pr
working-directory: ./fastlane
- name: ci/upload-android-fork-pr-build
id: ci-upload-android-fork-pr-build
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: android-fork-build-pr-${{ github.run_id }}
path: "*.apk"
- name: ci/post-artifact-link-to-pr
if: github.event_name == 'pull_request'
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const prNumber = '${{ github.event.pull_request.number }}';
const installUrl = `https://pr-builds.mattermost.com/mattermost-mobile/${prNumber}/merge/Mattermost_Beta.apk`;
const message = `### Android PR Build\n\nYou can install the Android APK build directly from:\n- [Install from PR Builds](${installUrl})\n\nCommit: ${{ github.event.pull_request.head.sha }}`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: message
});