| 1 | name: CI |
| 2 | on: |
| 3 | push: |
| 4 | branches: [main] |
| 5 | workflow_dispatch: |
| 6 | inputs: |
| 7 | greeting: |
| 8 | description: What to say |
| 9 | default: hi |
| 10 | env: |
| 11 | WORKFLOW_LEVEL: from-the-workflow |
| 12 | jobs: |
| 13 | setup: |
| 14 | runs-on: ubuntu-latest |
| 15 | outputs: |
| 16 | version: ${{ steps.version.outputs.value }} |
| 17 | matrix: ${{ steps.matrix.outputs.json }} |
| 18 | steps: |
| 19 | - uses: actions/checkout@v7 |
| 20 | - id: version |
| 21 | run: echo "value=1.2.$GITHUB_RUN_NUMBER" >> "$GITHUB_OUTPUT" |
| 22 | - id: matrix |
| 23 | run: echo 'json={"node":[24,26]}' >> "$GITHUB_OUTPUT" |
| 24 | - name: Show the context |
| 25 | run: | |
| 26 | echo "::group::Context" |
| 27 | echo "repo=${{ github.repository }} ref=${{ github.ref_name }} sha=${{ github.sha }}" |
| 28 | echo "event=${{ github.event_name }} actor=${{ github.actor }}" |
| 29 | echo "var=${{ vars.GREETING }} secret=${{ secrets.DEMO_SECRET }}" |
| 30 | echo "workflow env=$WORKFLOW_LEVEL" |
| 31 | echo "::endgroup::" |
| 32 | echo "::notice title=Version::Building ${{ steps.version.outputs.value }}" |
| 33 | ls -la |
| 34 | test: |
| 35 | needs: setup |
| 36 | runs-on: ${{ matrix.os || 'ubuntu-latest' }} |
| 37 | strategy: |
| 38 | matrix: ${{ fromJSON(needs.setup.outputs.matrix) }} |
| 39 | steps: |
| 40 | - uses: actions/checkout@v7 |
| 41 | - uses: actions/setup-node@v7 |
| 42 | with: |
| 43 | node-version: ${{ matrix.node }} |
| 44 | - run: node --version |
| 45 | - name: Pass state between steps |
| 46 | run: echo "FROM_EARLIER=set by step one" >> "$GITHUB_ENV" |
| 47 | - run: echo "Reading it back -> $FROM_EARLIER (version ${{ needs.setup.outputs.version }})" |
| 48 | - name: Allowed to fail |
| 49 | continue-on-error: true |
| 50 | run: exit 3 |
| 51 | - name: Only on Node 22 |
| 52 | if: matrix.node == 24 |
| 53 | run: echo "hash=${{ hashFiles('**/*.yml') }}" |
| 54 | report: |
| 55 | needs: [setup, test] |
| 56 | if: always() |
| 57 | runs-on: ubuntu-latest |
| 58 | steps: |
| 59 | - run: echo "test result was ${{ needs.test.result }}" |
| 60 | - shell: python |
| 61 | run: | |
| 62 | import os |
| 63 | print("python says", os.environ["GITHUB_REPOSITORY"]) |