Overview
The project automates, customizes, and performs software development workflows such as test, package, and release in the GitHub Actions repository.
Billing
Regarding billing for GitHub Actions,
- Public repository and self-hosted runner, free use of GitHub Actions.
- Github Free 2000 minutes of Linux or 1000 minutes of Windows or 200 minutes of macOS per month.
Workfile
GitHub Actions syntax, using YAML syntax, put.github/workflows.
name
Optional, workflow name.
on
Trigger workflow, commonly used have < push | pull_request >.
jobs
Job group, which is executed in parallel by default.
runs-on
GitHub hosts a runner for iOS projects using MacOS – Latest.
steps
The task group
Testing
Take the iOS project as an example, to build tests, you need to execute swiftLint, Pod lib Lint, xcodeBuild test. Xchelper can provide convenient commands.
Add the.iOS_test.yml file
mkdir -p .github/workflows
vi .github/workflows/iOS-test.yml
Copy the code
name: iOS testing
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
name: Build and Test default scheme using any available iPhone simulator
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- name: setup
run: |
sh -c "$(curl -fsSL https://raw.githubusercontent.com/BlueIntent/xchelper/main/scripts/install.sh)"
- name: lint
run: |
xchelper swiftlint
xchelper pod-lib-lint
- name: xcodebuild-test
run: |
xchelper install
xchelper test
Copy the code
After submission, you can view the GitHub Actions progress.
Add workflow status badges
github badge
Add workflow status badges
https://github.com/<OWNER>/<REPOSITORY>/actions/workflows/<WORKFLOW_FILE>/badge.svg
Copy the code
Such as
shields badge
Or use shields. IO /category/bu…
https://img.shields.io/github/workflow/status/:user/:repo/:workflow
Copy the code
Such asNote: The workflow in shields is not the wokrFlow file name, but the workflow Flie configuration name
Examples
- QiuZhiFei/ Ci-examples can be directly edited, PR test CI.
Automate Task
For making the owner/repo
git config --get remote.origin.url | sed -e 's/\(https:\/\/github.com\/\)//g' | sed -e 's/\([email protected]:\)//g' | sed -e 's/\.git//g' | awk {'print $0'}
Copy the code
Get the Github Actions URL
git config --get remote.origin.url | sed -e 's/\(https:\/\/github.com\/\)//g' | sed -e 's/\([email protected]:\)//g' | sed -e 's/\.git//g' | awk {'print "https://github.com/" $0 "/actions"'}
Copy the code
View all Actions runs
owner_repo=`git config --get remote.origin.url | sed -e 's/\(https:\/\/github.com\/\)//g' | sed -e 's/\([email protected]:\)//g' | sed -e 's/\.git//g' | awk {'print $0'}`
open "https://api.github.com/repos/$owner_repo/actions/runs"
Copy the code
Delete all actions
#! /bin/bash # 1. should install https://github.com/stedolan/jq # 2. should install https://github.com/httpie/httpie # 3. Should set access_token access_token = '# # for making the owner/repo owner_repo = ` git config -- get remote. Origin. The url | sed -e 's / \' (/ / / https:\/\/github.com / / g | sed -e 's / \ ([email protected]: \) / / g' | sed -e 's / \. Git / / g' | awk {' print $0} ` # # Github repo Actions runs (top 100) actions_runs_ids=(' HTTP "https://api.github.com/repos/$owner_repo/actions/runs?per_page=100" | jq .workflow_runs | jq '.[]|.id'` ) echo ${actions_runs_ids[@]} ## Delete actions run for run_id in ${actions_runs_ids[@]}; do http DELETE "https://api.github.com/repos/$owner_repo/actions/runs/$run_id?access_token=$access_token" Accept:"application/vnd.github.v3+json" doneCopy the code
References
- GitHub Actions workflow syntax
- Making Actions profile
- GitHub REST API documentation