|
| 1 | +# https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/evaluate-expressions-in-workflows-and-actions |
| 2 | +name: expressions |
| 3 | +on: push |
| 4 | + |
| 5 | +jobs: |
| 6 | + expressions: |
| 7 | + runs-on: ubuntu-latest |
| 8 | + steps: |
| 9 | + - name: Literals |
| 10 | + env: |
| 11 | + myNull: ${{ null }} |
| 12 | + myBoolean: ${{ false }} |
| 13 | + myIntegerNumber: ${{ 711 }} |
| 14 | + myFloatNumber: ${{ -9.2 }} |
| 15 | + myHexNumber: ${{ 0xff }} |
| 16 | + myExponentialNumber: ${{ -2.99e-2 }} |
| 17 | + myString: Mona the Octocat |
| 18 | + myStringInBraces: ${{ 'It''s open source!' }} |
| 19 | + |
| 20 | + - name: Operators |
| 21 | + env: |
| 22 | + MY_ENV_VAR: ${{ github.ref == 'refs/heads/master' && 'value_for_main_branch' || 'value_for_other_branches' }} |
| 23 | + |
| 24 | + - name: Functions |
| 25 | + if: contains(fromJSON('["push", "pull_request"]'), github.event_name) # true |
| 26 | + env: |
| 27 | + contains: contains('Hello world', 'llo') # true |
| 28 | + startsWith: startsWith('Hello world', 'He') # true |
| 29 | + endsWith: endsWith('Hello world', 'ld') # true |
| 30 | + format: format('Hello {0} {1} {2}', 'Mona', 'the', 'Octocat') # 'Hello Mona the Octocat' |
| 31 | + formatEscapingBraces: format('{{Hello {0} {1} {2}!}}', 'Mona', 'the', 'Octocat') # '{Hello Mona the Octocat!}' |
| 32 | + join: join(github.event.issue.labels.*.name, ', ') # 'bug, help wanted' |
| 33 | + toJSON: toJSON(job) # { "status": "success" } |
| 34 | + fromJSON: fromJSON('["push", "pull_request"]' |
| 35 | + hashFiles: hashFiles('**/package-lock.json') |
| 36 | + |
| 37 | + - name: sucess |
| 38 | + if: ${{ success() }} |
| 39 | + |
| 40 | + - name: always |
| 41 | + if: ${{ always() }} |
| 42 | + |
| 43 | + - name: cancelled |
| 44 | + if: ${{ cancelled() }} |
| 45 | + |
| 46 | + - name: failure |
| 47 | + if: ${{ failure() }} |
0 commit comments