steps:-uses:actions/setup-node@74bc508# Reference a specific commit-uses:actions/setup-node@v1# Reference the major version of a release-uses:actions/setup-node@v1.2# Reference a minor version of a release-uses:actions/setup-node@master# Reference a branch
示例:
jobs:build:# Job name is Greetingname:Greeting# This job runs on Linuxruns-on:ubuntu-lateststeps: # This step uses GitHub's hello-world-javascript-action: https://github.com/actions/hello-world-javascript-action
-name:Helloworlduses:actions/hello-world-javascript-action@v1with:who-to-greet:'Mona the Octocat'id:hello# This step prints an output (time) from the previous step's action.-name:Echothegreeting's time run: echo 'Thetimewas ${{ steps.hello.outputs.time }}.'
3.5 引用action
#public repo{owner}/{repo}@{ref} or{owner}/{repo}/{path}@{ref}.#same repo {owner}/{repo}@{ref} or./path/to/dir|--hello-world (repository)||__.github|└──workflows|└──my-first-workflow.yml|└──actions||__hello-world-action|└──action.ymljobs:build:runs-on:ubuntu-lateststeps:# This step checks out a copy of your repository.-uses:actions/checkout@v1# This step references the directory that contains the action.-uses:../github/actions/hello-world-action#docker containerdocker://{image}:{tag}示例:jobs:my_first_job:steps:-name:Myfirststepuses:docker://gcr.io/cloud-builders/gradle-name:InstallDependenciesrun:npminstallshell:bash
steps:-name:Myfirstactionenv:GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}FIRST_NAME:MonaLAST_NAME:Octocatsteps:-name:Helloworldactionwith:# Set the secret as an inputsuper_secret: ${{ secrets.SuperSecret }}env:# Or as an environment variablesuper_secret: ${{ secrets.SuperSecret }}
name:BuildandDeployon:push:branches:-masterjobs:build-and-deploy:runs-on:ubuntu-lateststeps:-name:Checkout������️uses:actions/checkout@v1-name:BuildandDeployuses:JamesIves/github-pages-deploy-action@releases/v2env:ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}## GitHub 密钥 ACCESS_TOKEN 是在第二步Settings的Secrets中新增时定义的Name,要保持一致BASE_BRANCH:master# The branch the action should deploy from.BRANCH:gh-pages# The branch the action should deploy to.FOLDER:build# The folder the action should deploy. BUILD_SCRIPT: npm install && npm run-script build # The build script the action should run prior to deploying.