Skip to content

joshdholtz/fastlane-plugin-github_action

Repository files navigation

GitHub Action plugin for fastlane

fastlane Plugin Badge Gem Version

About github_action

GitHub Actions makes it easy to build, test, and deploy your code right from GitHub. However, etting up fastlane to work with match on GitHub Actions can take bit of juggling and manual work 😔

But fastlane-plugin-github_action to the rescue 💪

This plugin will:

1. Prompt you if setup_ci is not found in your Fastfile

Running fastlane on a CI requires the environment to be setup properly. Calling the setup_ci action does that by configuring a new keychain that will be used for code signing with match

2. Create a Deploy Key on your match repository to be used from your GitHub Action

A Deploy Key is needed for GitHub Actions to access your match repository. This action creates a new SSH key and uses the public key for the Deploy Key on your match repository.

This will only get executed if the match_org and match_repo options are specified.

3. Set the Deploy Key private key in secrets (along with secrets in your dotenv file(s)

The private key created for the Deploy Key is store encrypted in your repository secrets. The private key is stored under the name MATCH_DEPLOY_KEY.

Encrypted secrets will also get set for environment variables from dotenv files specified by the dotenv_paths option.

4. Generate a Workflow YAML file to use

A Workflow YAML file is created at .github/workflows/fastlane.yml. This will enable your repository to start running GitHub Actions right away - once committed and pushed 😉. The Workflow YAML template will add the Deploy Key private key into the GitHub Action by loading it from the MATCH_DEPLOY_KEY secret and executing ssh-add. All of your other encrypted secrets will also be loaded into environment variables for you as well.

An example can be seen here.

Getting Started

This project is a fastlane plugin. To get started with fastlane-plugin-github_action, add it to your project by running:

fastlane add_plugin github_action

Requirements

fastlane-plugin-github_action depends on rbnacl which uses libsodium

For macOS, libsodium can be installed with:

brew install libsodium

See https://github.com/RubyCrypto/rbnacl/wiki/Installing-libsodium for more installation instructions.

Usage

fastlane-plugin-github_action can be execute either direction on the command line with bundle exec fastlane run github_action or by adding github_action to your Fastfile.

CLI

bundle exec fastlane run github_action \
  api_token:"your-github-personal-access-token-with-all-repo-permissions" \
  org:"your-org" \
  repo:"your-repo"

or

bundle exec fastlane run github_action \
  api_token:"your-github-personal-access-token-with-all-repo-permissions" \
  org:"your-org" \
  repo:"your-repo" \
  match_org:"your-match-repo-org" \
  match_repo:"your-match-repo" \
  dotenv_paths:"fastlane/.env.secret,fastlane/.env.secret2"

In Fastfile

lane :init_ci do
  github_action(
    api_token: "your-github-personal-access-token-with-all-repo-permissions",
    org: "your-org",
    repo: "your-repo",
    match_org: "your-match-repo-org", # optional
    match_repo: "your-match-repo", # optional
    dotenv_paths: ["fastlane/.env.secret", "fastlane/.env.secret2"] # optional
  )
end

Help

Once installed, information and help for an action can be printed out with this command:

fastlane action github_action # or any action included with this plugin

Options

Key Environment Variable Description
server_url FL_GITHUB_API_SERVER_URL The server url. e.g. 'https://your.internal.github.host/api/v3' (Default: 'https://api.github.com')
api_token FL_GITHUB_API_TOKEN Personal API Token for GitHub - generate one at https://github.com/settings/tokens
org FL_GITHUB_ACTIONS_ORG Name of organization of the repository for GitHub Actions
repo FL_GITHUB_ACTIONS_REPO Name of repository for GitHub Actions
match_org FL_GITHUB_ACTIONS_MATCH_ORG Name of organization of the match repository
match_repo FL_GITHUB_ACTIONS_MATCH_REPO Name of match repository
dotenv_paths FL_GITHUB_ACTINOS_DOTENV_PATHS Paths of .env files to parse

Example

Check out the example Fastfile to see how to use this plugin. Try it by cloning the repo, running fastlane install_plugins and bundle exec fastlane test.

Run tests for this plugin

To run both the tests, and code style validation, run

rake

To automatically fix many of the styling issues, use

rubocop -a

Issues and Feedback

For any other issues and feedback about this plugin, please submit it to this repository.

Troubleshooting

If you have trouble using plugins, check out the Plugins Troubleshooting guide.

Using fastlane Plugins

For more information about how the fastlane plugin system works, check out the Plugins documentation.

About fastlane

fastlane is the easiest way to automate beta deployments and releases for your iOS and Android apps. To learn more, check out fastlane.tools.

About

A plugin for setting up fastlane on GitHub Actions

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages