Coder Social home page Coder Social logo

fastlane-plugin-github_action's Introduction

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.

fastlane-plugin-github_action's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

fastlane-plugin-github_action's Issues

Specifying match_org and match_repo prompts for user input

Running the git_action() fails in my GitHub Action because it's prompting for user input:

[15:03:42]: Driving the lane 'ios beta' ๐Ÿš€
[15:03:42]: ---------------------------
[15:03:42]: --- Step: github_action ---
[15:03:42]: ---------------------------
[15:03:42]: The github_actions plugin is working!
[15:03:44]: Deploy Key for the match repo already exists... Delete it?
[15:03:44]: Could not retrieve response as fastlane runs in non-interactive mode

Relevant part of my Fastfile:

default_platform(:ios)

platform :ios do
  desc "Push a new beta build to TestFlight"
  lane :beta do

    github_action(
      api_token: "*****",
      org: "some-org",
      repo: "some-repo",
      match_org: "some-org",
      match_repo: "match-repo"
    )

Is there an read-only option, or some other way to force it to delete the key or not?

Support for saving the MATCH_DEPLOY_KEY to organization secrets

I am running into trouble running this on a second project.

It works well for the first project, but it fails when I try to use it to apply the MATCH_DEPLOY_KEY to a second project due to a deploy key already existing.

I get this error when it runs.
https://puu.sh/JtqJq/d2b64245be.png

The best solution I can think of would be if I could get the MATCH_DEPLOY_KEY to be applied to the Actions Secrets at the organization level allowing all projects in the organization the ability to use the match repo.

Release new version on RubyGems?

Hi!

I'm using this plugin in a way that requires version 1.1.0.

However, the latest version on rubygems.org (and hence the version installed by running fastlane add_plugin github_action is 1.0.0.

I was able to work around this by specifying a git repo for the plugin in my Pluginfile, but it would be nice (and presumably useful for other folks) if a new version was pushed to Rubygems.

Let me know if there's anything I can do to help with that! I assume the answer is no, but happy to lend time on the off-chance that's not the case.

GET repo keys cURL returning "404"

I'm attempting to use fastlane match to manage my certs and I haven't been able to get it to work properly.

I have been following the instructions on your blog https://www.joshholtz.com/blog/2020/05/19/fastlane-plugin-for-setting-up-github-actions.html and have set everything up as instructed but when I run the action I get

    [15:47:40]: ---------------------------
    [15:47:40]: --- Step: github_action ---
    [15:47:40]: ---------------------------
    [15:47:40]: The github_actions plugin is working!
    [15:47:41]: ---
    [15:47:41]: Request failed:
    GET: https://api.github.com/repos/***/keys
    [15:47:41]: Headers:
    {"User-Agent"=>"fastlane-github_api", "Authorization"=>"Basic ***"}
    [15:47:41]: ---
    [15:47:41]: Response:
    [15:47:41]: {"message":"Not Found","documentation_url":"https://docs.github.com/rest/reference/repos#list-deploy-keys"}

I have checked and the org and repo variables are correct, my yml looks like this:

    jobs:
      setup:
        runs-on: ubuntu-latest
        steps:
          - uses: actions/[email protected]
          - uses: ruby/setup-ruby@v1
            with:
              ruby-version: 2.6
              bundler-cache: true
    
          - name: Build iOS
            shell: bash
            run: |
              bundle exec fastlane ios init_ci
            env:
              APP_STORE_CONNECT_ISSUER_ID: ${{ secrets.IOS_DEV_APPSTORE_ISSUER_ID }}
              APP_STORE_CONNECT_KEY: ${{ secrets.IOS_DEV_APPSTORE_P8 }}
              APP_STORE_CONNECT_KEY_ID: ${{ secrets.IOS_DEV_APPSTORE_KEY_ID }}
    
              GH_PAT: ${{ secrets.PAT_VALUE }}
              GITHUB_REPOSITORY: ${{ env.GITHUB_REPOSITORY }}
              MATCH_REPOSITORY: ${{ secrets.MATCH_REPOSITORY }}

And the init_ci in my fastfile looks like this:

      org, repo = (ENV["GITHUB_REPOSITORY"]||"").split("/")
      match_org, match_repo = (ENV["MATCH_REPOSITORY"]||"").split("/")
      
      platform :ios do
        lane :init_ci do
          setup_ci
          github_action(
            api_token: ENV["GH_PAT"],
            org: org,
            repo: repo,
            match_org: match_org,
            match_repo: match_repo,
            writable_deploy_key: true
          )
        end

my github PAT is set up for repo, workflow, and even admin privileges and is being accessed.
Was there a change to the github api? the "list_deploy_keys" is no longer a part of the github API documentation that the error is linking to

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.