File tree Expand file tree Collapse file tree 3 files changed +60
-4
lines changed
Expand file tree Collapse file tree 3 files changed +60
-4
lines changed Original file line number Diff line number Diff line change 5555 env :
5656 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
5757
58+ # handle error
59+ - name : " Handle error"
60+ continue-on-error : true
61+ uses : ./
62+ id : get_release
63+ with :
64+ route : GET /repos/{owner}/{repo}/releases/v0.9.9
65+ owner : octokit
66+ repo : request-action
67+ env :
68+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
69+ - run : " echo Release cound not be found. Request failed with status ${{ steps.get_release.outputs.status }}"
70+ if : ${{ failure() }}
71+
72+ issues :
73+ name : " [TEST] Issues"
74+ runs-on : ubuntu-latest
75+ steps :
76+ - uses : actions/checkout@master
77+ - uses : actions/setup-node@v2
78+ with :
79+ node-version : " 12.x"
80+ - run : " npm ci"
81+ - run : " npm run build"
82+
5883 # See https://github.com/octokit/request-action/issues/71
59- - name : " Un-encode {repo} URL parameter when it's set to github.repository"
84+ - name : " Un-encode {repo} URL parameter when it's set to github.repository (#71) "
6085 uses : ./
6186 with :
6287 route : GET /repos/{repository}
Original file line number Diff line number Diff line change 7575 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7676` ` `
7777
78+ Handle errors
79+
80+ ```
81+ name: Log latest release
82+ on:
83+ push:
84+ branches:
85+ - master
86+
87+ jobs:
88+ handleError:
89+ runs-on: ubuntu-latest
90+ steps:
91+ - uses: octokit/request-
[email protected] 92+ id: get_release
93+ with:
94+ route: GET /repos/{owner}/{repo}/releases/v0.9.9
95+ owner: octokit
96+ repo: request-action
97+ env:
98+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
99+ - run: "Release found: ${{ steps.get_release.outputs.data }}"
100+ - name: "Release cound not be found. Request failed with status ${{ steps.get_release.outputs.status }}
101+ if: ${{ failure() }}
102+ ```
103+
78104## Inputs
79105
80106To use request body parameters, simply pass in an `input` matching the parameter name. See previous examples.
89115with:
90116 # As JSON
91117 body: ${{ toJSON(env.REQUEST_BODY) }}
92-
118+
93119 # As block scalar
94120 body: |
95121 |
Original file line number Diff line number Diff line change @@ -7,6 +7,8 @@ const { Octokit } = require("@octokit/action");
77main ( ) ;
88
99async function main ( ) {
10+ const time = Date . now ( ) ;
11+
1012 try {
1113 const octokit = new Octokit ( ) ;
1214 const { route, ...parameters } = getAllInputs ( ) ;
@@ -35,8 +37,6 @@ async function main() {
3537 core . debug ( `parameters: ${ inspect ( parameters ) } ` ) ;
3638 core . debug ( `parsed request options: ${ inspect ( requestOptions ) } ` ) ;
3739
38- const time = Date . now ( ) ;
39-
4040 const { status, headers, data } = await octokit . request ( requestOptions ) ;
4141
4242 core . info ( `< ${ status } ${ Date . now ( ) - time } ms` ) ;
@@ -45,6 +45,11 @@ async function main() {
4545 core . setOutput ( "headers" , JSON . stringify ( headers , null , 2 ) ) ;
4646 core . setOutput ( "data" , JSON . stringify ( data , null , 2 ) ) ;
4747 } catch ( error ) {
48+ if ( error . status ) {
49+ core . info ( `< ${ error . status } ${ Date . now ( ) - time } ms` ) ;
50+ }
51+
52+ core . setOutput ( "status" , error . status ) ;
4853 core . debug ( inspect ( error ) ) ;
4954 core . setFailed ( error . message ) ;
5055 }
You can’t perform that action at this time.
0 commit comments