Overview

Create your own actions and post them to GitHub marketplace

Create Marketplace apps

Create the ios-helper-Action project

mkdir iOS-helper-action
Copy the code

Create action metadata file

action.yml
Copy the code
name: 'iOS Helper Action'
description: 'Tool for iOS developers to automate tedious tasks like swiftlint, pod-lib-lint, install, run, test.'
inputs:
  action:  # action
    description: 'automate tedious tasks'
    required: true
runs:
  using: "node12"
  main: "dist/index.js"
Copy the code

Submit, mark, and push actions to GitHub

Write index. Js

echo 'node_modules/' > .gitignore

npm install @actions/core
npm install @actions/exec

vi index.js
Copy the code

Index.js is only responsible for receiving parameters and forwarding them to build.sh

const core = require("@actions/core"); const exec = require("@actions/exec"); async function run() { try { // Validate action if ( ! core.getInput("action") ) { throw new Error("action missing or in the wrong format."); } const action = core.getInput("action"); console.log(`Action: ${action}`); // Execute build.sh await exec.exec(`bash ${__dirname}/.. /build.sh ${action}`); } catch (error) { core.setFailed(error.message); } } run();Copy the code

Complete the operations in build.sh

vi build.sh
Copy the code
#! /bin/bash if ! (which xchelper >/dev/null); then echo "Installing xchelper" sh -c "$(curl -fsSL https://raw.githubusercontent.com/BlueIntent/xchelper/main/scripts/install.sh)" echo "Done!" fi xchelper $1Copy the code

Compile the index. Js

npm i -g @vercel/ncc --verbose
ncc build index.js --license licenses.txt
Copy the code

Add the tag and commit

Git tag v0.0.1 git pushCopy the code

test

After committing, modify the workfile reference

- uses: BlueIntent/[email protected]
  with:
    action: 'swiftlint'
Copy the code

release

After passing the test, you can publish to Marketplace. You can see it on github

Copy the code

The iOS Helper Action is published successfully

Usage

- name: swiftlint
  uses: BlueIntent/[email protected]
  with:
    action: 'swiftlint'
Copy the code

See ios-test-with-xchelper-action. yml, edit PR directly, test directly.

References

  • GitHub Actions Creates JavaScript Actions
  • GitHub Actions metadata syntax

Homepage

  • Github.com/BlueIntent/…